lambda-essentials-ts 6.0.0 → 6.1.0

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.
@@ -3,6 +3,6 @@ export declare class ClientException extends Exception {
3
3
  readonly serviceName: string;
4
4
  readonly originalStatusCode?: number;
5
5
  private static readonly statusCodeMap;
6
- constructor(serviceName: string, originalStatusCode?: number, details?: any, statusCodeMapOverride?: Record<number, number>);
6
+ constructor(serviceName: string, originalStatusCode?: number, details?: any, originalMessage?: string, statusCodeMapOverride?: Record<number, number>);
7
7
  private static convertStatusCode;
8
8
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClientException = void 0;
4
4
  const exception_1 = require("./exception");
5
5
  class ClientException extends exception_1.Exception {
6
- constructor(serviceName, originalStatusCode, details, statusCodeMapOverride) {
7
- super(`Dependent service "${serviceName}" returned error`, ClientException.convertStatusCode(originalStatusCode, statusCodeMapOverride), details);
6
+ constructor(serviceName, originalStatusCode, details, originalMessage, statusCodeMapOverride) {
7
+ super(`Dependent service "${serviceName}" returned error: ${originalMessage !== null && originalMessage !== void 0 ? originalMessage : 'Unknown error'}`, ClientException.convertStatusCode(originalStatusCode, statusCodeMapOverride), details);
8
8
  this.serviceName = serviceName;
9
9
  this.originalStatusCode = originalStatusCode;
10
10
  }
@@ -130,7 +130,7 @@ class HttpClient {
130
130
  const hostname = ((_a = error.config) === null || _a === void 0 ? void 0 : _a.url)
131
131
  ? new url_1.URL(error.config.url, error.config.baseURL).hostname
132
132
  : 'N/A';
133
- throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, this.clientExceptionStatusCodeMapOverride);
133
+ throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.message, this.clientExceptionStatusCodeMapOverride);
134
134
  });
135
135
  this.client.interceptors.response.use((response) => {
136
136
  if (this.logOptions.enabledLogs.includes(HttpLogType.responses)) {
@@ -169,7 +169,7 @@ class HttpClient {
169
169
  const hostname = ((_a = error.config) === null || _a === void 0 ? void 0 : _a.url)
170
170
  ? new url_1.URL(error.config.url, error.config.baseURL).hostname
171
171
  : 'N/A';
172
- throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, this.clientExceptionStatusCodeMapOverride);
172
+ throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.message, this.clientExceptionStatusCodeMapOverride);
173
173
  });
174
174
  }
175
175
  static extractRequestLogData(requestConfig) {
package/lib/util.d.ts CHANGED
@@ -7,4 +7,5 @@ export declare function serializeAxiosError(error: AxiosError): SerializedAxiosE
7
7
  export interface SerializedAxiosError {
8
8
  status: number;
9
9
  details: any;
10
+ message?: string;
10
11
  }
package/lib/util.js CHANGED
@@ -53,7 +53,8 @@ function serializeAxiosError(error) {
53
53
  const { status, data } = error.response;
54
54
  return {
55
55
  status: (_a = data.originalStatusCode) !== null && _a !== void 0 ? _a : status,
56
- details: data.details && Object.keys(data.details).length > 0 ? data.details : data, // Prevent wrapping of Exception
56
+ details: data.details && Object.keys(data.details).length > 0 ? data.details : data,
57
+ message: data.message,
57
58
  };
58
59
  }
59
60
  exports.serializeAxiosError = serializeAxiosError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-essentials-ts",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.",
5
5
  "main": "lib/index.js",
6
6
  "private": false,