@nu-art/ts-common 0.201.49 → 0.201.51

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.
@@ -137,6 +137,8 @@ export declare class ApiException<E extends TS_Object | void = void> extends Cus
137
137
  readonly responseBody: ErrorResponse<E>;
138
138
  readonly responseCode: number;
139
139
  readonly setErrorBody: (errorBody: ErrorBody<E>) => this;
140
- constructor(responseCode: number, debugMessage?: string, cause?: Error);
140
+ constructor(responseCode: number, causeOrMessage?: string | Error, cause?: Error);
141
+ private static getMessage;
142
+ private static getCause;
141
143
  }
142
144
  export declare function isCustomException(e: Error): boolean;
@@ -21,6 +21,7 @@
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.isCustomException = exports.ApiException = exports.AssertionException = exports.WhoCallthisException = exports.DontCallthisException = exports.HasDependenciesException = exports.ThisShouldNotHappenException = exports.NotImplementedYetException = exports.MUSTNeverHappenException = exports.ImplementationMissingException = exports.BadImplementationException = exports.Exception = exports.CustomException = exports.isErrorOfType = void 0;
24
+ const utils_1 = require("../logger/utils");
24
25
  /**
25
26
  * # <ins>isErrorOfType</ins>
26
27
  *
@@ -193,15 +194,21 @@ class AssertionException extends CustomException {
193
194
  }
194
195
  exports.AssertionException = AssertionException;
195
196
  class ApiException extends CustomException {
196
- constructor(responseCode, debugMessage, cause) {
197
- super(ApiException, `${responseCode}-${JSON.stringify(debugMessage)}`, cause);
197
+ constructor(responseCode, causeOrMessage, cause) {
198
+ super(ApiException, `${responseCode}${ApiException.getMessage(causeOrMessage)}`, ApiException.getCause(causeOrMessage, cause));
198
199
  this.responseBody = {};
199
200
  this.setErrorBody = (errorBody) => {
200
201
  this.responseBody.error = errorBody;
201
202
  return this;
202
203
  };
203
204
  this.responseCode = responseCode;
204
- this.responseBody.debugMessage = debugMessage;
205
+ this.responseBody.debugMessage = (0, utils_1._logger_logException)(this);
206
+ }
207
+ static getMessage(causeOrMessage) {
208
+ return typeof causeOrMessage === 'string' ? `-${JSON.stringify(causeOrMessage)}` : '';
209
+ }
210
+ static getCause(causeOrMessage, cause) {
211
+ return typeof causeOrMessage != 'string' ? causeOrMessage : cause;
205
212
  }
206
213
  }
207
214
  exports.ApiException = ApiException;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-common",
3
- "version": "0.201.49",
3
+ "version": "0.201.51",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -32,7 +32,7 @@
32
32
  "run-tests": "ts-mocha --timeout 5000 -p src/test/tsconfig.json src/test/run-all-tests.ts"
33
33
  },
34
34
  "dependencies": {
35
- "export-to-csv": "^0.2.1",
35
+ "export-to-csv": "0.2.1",
36
36
  "moment": "^2.24.0",
37
37
  "node-forge": "^1.2.1",
38
38
  "uuid": "^9.0.0",
@@ -15,7 +15,7 @@ export declare const tsValidateStringMinLength: (length: number, mandatory?: boo
15
15
  export declare const tsValidateNumber: (mandatory?: boolean) => Validator<number>;
16
16
  export declare const tsValidateEnum: (enumType: TypedMap<number | string>, mandatory?: boolean) => Validator<number | string>;
17
17
  export declare const tsValidateBoolean: (mandatory?: boolean) => Validator<boolean>;
18
- export declare const tsValidateValue: (values: string[], mandatory?: boolean) => Validator<string>;
18
+ export declare const tsValidateValue: <T>(values: T[], mandatory?: boolean) => Validator<any>;
19
19
  export declare const tsValidateIsInRange: (ranges: [number, number][], mandatory?: boolean) => Validator<number>;
20
20
  export declare const tsValidateRange: (mandatory?: boolean) => Validator<[number, number] | undefined>;
21
21
  export declare const tsValidateRegexp: (regexp: RegExp, mandatory?: boolean) => Validator<string>;