@buka/nestjs-kit 4.4.9 → 4.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.4.10](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.9...v4.4.10) (2026-07-06)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 修复Keq处理错误信息丢失错误信息的问题 ([8a5f353](https://github.com/buka-ltd/npm.nestjs-kit/commit/8a5f353ff97a8ac4aff18b1ee3e015b503abc9e7))
9
+
3
10
  ## [4.4.9](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.4.8...v4.4.9) (2026-07-05)
4
11
 
5
12
 
package/dist/index.js CHANGED
@@ -8437,8 +8437,14 @@ function throwOnResponseError(options) {
8437
8437
  if (!ctx.response || ctx.response.status >= 200 && ctx.response.status < 400) return;
8438
8438
  const response = ctx.response;
8439
8439
  if (!response.headers.get("content-type")?.includes("application/json")) throw (0, _keq_request_exception.createExceptionByStatusCode)(response);
8440
- const body = await response.json();
8441
- if (body !== null && typeof body === "object" && "error" in body) try {
8440
+ let body;
8441
+ try {
8442
+ body = await response.json();
8443
+ } catch (err) {
8444
+ if (debug) logger.debug("响应体 JSON 解析失败,降级为状态码异常", err instanceof Error ? err.stack : err);
8445
+ throw (0, _keq_request_exception.createExceptionByStatusCode)(response);
8446
+ }
8447
+ if (body !== null && typeof body === "object" && "error" in body) {
8442
8448
  const { error } = body;
8443
8449
  const exceptionOptions = {
8444
8450
  code: error.code,
@@ -8450,13 +8456,13 @@ function throwOnResponseError(options) {
8450
8456
  404
8451
8457
  ].includes(response.status)
8452
8458
  };
8453
- if (errorDispatchers && error.code in errorDispatchers) {
8459
+ if (errorDispatchers && error.code in errorDispatchers) try {
8454
8460
  const ExceptionClass = errorDispatchers[error.code];
8455
8461
  throw new ExceptionClass(response.status, error.message, exceptionOptions);
8462
+ } catch (caught) {
8463
+ if (debug) logger.debug("自定义异常派发失败,降级为 BukaRequestException", caught instanceof Error ? caught.stack : caught);
8456
8464
  }
8457
8465
  throw new BukaRequestException(response.status, error.message, exceptionOptions);
8458
- } catch (caught) {
8459
- if (debug) logger.debug("解析响应错误体失败,降级为通用异常", caught instanceof Error ? caught.stack : caught);
8460
8466
  }
8461
8467
  throw (0, _keq_request_exception.createExceptionByStatusCode)(response);
8462
8468
  };