@voiceflow/exception 1.1.0 → 1.1.1

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.
Files changed (76) hide show
  1. package/README.md +45 -0
  2. package/build/cjs/base-error.interface.d.ts +15 -0
  3. package/build/cjs/base-error.interface.js +3 -0
  4. package/build/cjs/base-error.interface.js.map +1 -0
  5. package/build/cjs/client.exception.d.ts +16 -0
  6. package/build/cjs/client.exception.js +42 -0
  7. package/build/cjs/client.exception.js.map +1 -0
  8. package/build/cjs/error-code.enum.d.ts +2 -0
  9. package/build/cjs/error-code.enum.js +7 -0
  10. package/build/cjs/error-code.enum.js.map +1 -0
  11. package/build/cjs/error-message.interface.d.ts +5 -0
  12. package/build/cjs/error-message.interface.js +3 -0
  13. package/build/cjs/error-message.interface.js.map +1 -0
  14. package/build/cjs/error-payload.interface.d.ts +15 -0
  15. package/build/cjs/error-payload.interface.js +3 -0
  16. package/build/cjs/error-payload.interface.js.map +1 -0
  17. package/build/cjs/http/http-4xx.exception.d.ts +29 -0
  18. package/build/cjs/http/http-4xx.exception.js +35 -0
  19. package/build/cjs/http/http-4xx.exception.js.map +1 -0
  20. package/build/cjs/http/http-5xx.exception.d.ts +11 -0
  21. package/build/cjs/http/http-5xx.exception.js +17 -0
  22. package/build/cjs/http/http-5xx.exception.js.map +1 -0
  23. package/build/cjs/http/http-status.enum.d.ts +42 -0
  24. package/build/cjs/http/http-status.enum.js +49 -0
  25. package/build/cjs/http/http-status.enum.js.map +1 -0
  26. package/build/cjs/http/http.exception.d.ts +11 -0
  27. package/build/cjs/http/http.exception.js +22 -0
  28. package/build/cjs/http/http.exception.js.map +1 -0
  29. package/build/cjs/http/utils.d.ts +7 -0
  30. package/build/cjs/http/utils.js +16 -0
  31. package/build/cjs/http/utils.js.map +1 -0
  32. package/build/cjs/internal.exception.d.ts +22 -0
  33. package/build/cjs/internal.exception.js +65 -0
  34. package/build/cjs/internal.exception.js.map +1 -0
  35. package/build/cjs/main.d.ts +10 -0
  36. package/build/cjs/main.js +27 -0
  37. package/build/cjs/main.js.map +1 -0
  38. package/build/esm/base-error.interface.d.ts +15 -0
  39. package/build/esm/base-error.interface.js +2 -0
  40. package/build/esm/base-error.interface.js.map +1 -0
  41. package/build/esm/client.exception.d.ts +16 -0
  42. package/build/esm/client.exception.js +38 -0
  43. package/build/esm/client.exception.js.map +1 -0
  44. package/build/esm/error-code.enum.d.ts +2 -0
  45. package/build/esm/error-code.enum.js +4 -0
  46. package/build/esm/error-code.enum.js.map +1 -0
  47. package/build/esm/error-message.interface.d.ts +5 -0
  48. package/build/esm/error-message.interface.js +2 -0
  49. package/build/esm/error-message.interface.js.map +1 -0
  50. package/build/esm/error-payload.interface.d.ts +15 -0
  51. package/build/esm/error-payload.interface.js +2 -0
  52. package/build/esm/error-payload.interface.js.map +1 -0
  53. package/build/esm/http/http-4xx.exception.d.ts +29 -0
  54. package/build/esm/http/http-4xx.exception.js +32 -0
  55. package/build/esm/http/http-4xx.exception.js.map +1 -0
  56. package/build/esm/http/http-5xx.exception.d.ts +11 -0
  57. package/build/esm/http/http-5xx.exception.js +14 -0
  58. package/build/esm/http/http-5xx.exception.js.map +1 -0
  59. package/build/esm/http/http-status.enum.d.ts +42 -0
  60. package/build/esm/http/http-status.enum.js +46 -0
  61. package/build/esm/http/http-status.enum.js.map +1 -0
  62. package/build/esm/http/http.exception.d.ts +11 -0
  63. package/build/esm/http/http.exception.js +18 -0
  64. package/build/esm/http/http.exception.js.map +1 -0
  65. package/build/esm/http/utils.d.ts +7 -0
  66. package/build/esm/http/utils.js +12 -0
  67. package/build/esm/http/utils.js.map +1 -0
  68. package/build/esm/internal.exception.d.ts +22 -0
  69. package/build/esm/internal.exception.js +61 -0
  70. package/build/esm/internal.exception.js.map +1 -0
  71. package/build/esm/main.d.ts +10 -0
  72. package/build/esm/main.js +11 -0
  73. package/build/esm/main.js.map +1 -0
  74. package/build/tsconfig.build.tsbuildinfo +1 -0
  75. package/build/tsconfig.esm.tsbuildinfo +1 -0
  76. package/package.json +2 -2
package/README.md CHANGED
@@ -1,3 +1,48 @@
1
1
  # exception
2
2
 
3
3
  Voiceflow standard exceptions and error codes
4
+
5
+ ![image](https://user-images.githubusercontent.com/3784470/200739313-495941eb-dab0-4801-87ae-182f1c43ff9e.png)
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ yarn add @voiceflow/exception
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### HTTP Exceptions
16
+
17
+ These exceptions are meant to be caught and transformed by express middleware or NestJS error filters.
18
+ Named exceptions exist for all standard HTTP 4xx and 5xx error codes.
19
+
20
+ ```ts
21
+ import { ErrorCode, BadRequestException, NotFoundException, InternalServerErrorException, BadGatewayException } from '@voiceflow/exception';
22
+
23
+ // default error message
24
+ throw new BadRequestException();
25
+
26
+ // custom error message
27
+ throw new NotFoundException('implementation broken');
28
+
29
+ // internal error code
30
+ throw new BadGatewayException({ message: 'request timed out', errorCode: ErrorCode.THIRD_PARTY_TIMEOUT });
31
+
32
+ try {
33
+ // do something
34
+ } catch (err) {
35
+ // wrap internal error
36
+ throw new InternalServerErrorException({ message: 'implementation error', cause: err });
37
+ }
38
+ ```
39
+
40
+ ### Internal Exceptions
41
+
42
+ These exceptions can be used within business logic but should caught and wrapped or handled before being returned from a service.
43
+
44
+ ```ts
45
+ import { InternalException } from '@voiceflow/exception';
46
+
47
+ throw new InternalException('some internal error');
48
+ ```
@@ -0,0 +1,15 @@
1
+ import { ErrorCode } from './error-code.enum';
2
+ export interface BaseError {
3
+ /**
4
+ * message describing this error
5
+ */
6
+ message: string;
7
+ /**
8
+ * additional details attached to the error
9
+ */
10
+ details?: object;
11
+ /**
12
+ * platform-internal error code
13
+ */
14
+ errorCode?: ErrorCode;
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=base-error.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-error.interface.js","sourceRoot":"","sources":["../../src/base-error.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { ErrorCode } from './error-code.enum';
2
+ import { ErrorPayload } from './error-payload.interface';
3
+ export declare class ClientException extends Error implements ErrorPayload {
4
+ static instanceOf(err: any): err is ClientException;
5
+ response: Response;
6
+ statusCode: number;
7
+ statusText: string;
8
+ errorCode?: ErrorCode;
9
+ cause?: string;
10
+ details?: object;
11
+ constructor(response: Response);
12
+ private extractDetailedError;
13
+ private extractOpaqueError;
14
+ getCause(): string | undefined;
15
+ build(): Promise<this>;
16
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientException = void 0;
4
+ class ClientException extends Error {
5
+ constructor(response) {
6
+ super();
7
+ this.name = this.constructor.name;
8
+ this.response = response.clone();
9
+ this.statusCode = response.status;
10
+ this.statusText = response.statusText;
11
+ }
12
+ static instanceOf(err) {
13
+ return err instanceof ClientException;
14
+ }
15
+ extractDetailedError(body) {
16
+ this.message = body.message || this.response.statusText;
17
+ if (body.cause)
18
+ this.cause = body.cause;
19
+ if (body.details)
20
+ this.details = body.details;
21
+ if (body.errorCode)
22
+ this.errorCode = body.errorCode;
23
+ }
24
+ extractOpaqueError(text) {
25
+ this.message = text || this.response.statusText;
26
+ }
27
+ getCause() {
28
+ return this.cause;
29
+ }
30
+ async build() {
31
+ const text = await this.response.text();
32
+ try {
33
+ this.extractDetailedError(JSON.parse(text));
34
+ }
35
+ catch (_a) {
36
+ this.extractOpaqueError(text);
37
+ }
38
+ return this;
39
+ }
40
+ }
41
+ exports.ClientException = ClientException;
42
+ //# sourceMappingURL=client.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.exception.js","sourceRoot":"","sources":["../../src/client.exception.ts"],"names":[],"mappings":";;;AAGA,MAAa,eAAgB,SAAQ,KAAK;IAiBxC,YAAY,QAAkB;QAC5B,KAAK,EAAE,CAAC;QACR,IAA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@
1
+ export declare enum ErrorCode {
2
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorCode = void 0;
4
+ var ErrorCode;
5
+ (function (ErrorCode) {
6
+ })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
7
+ //# sourceMappingURL=error-code.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-code.enum.js","sourceRoot":"","sources":["../../src/error-code.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAAY;AAAxB,WAAY,SAAS;AAAE,CAAC,EAAZ,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAAG"}
@@ -0,0 +1,5 @@
1
+ import { BaseError } from './base-error.interface';
2
+ export interface DetailedErrorMessage extends BaseError {
3
+ cause?: unknown;
4
+ }
5
+ export declare type ErrorMessage = string | Error | DetailedErrorMessage;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=error-message.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-message.interface.js","sourceRoot":"","sources":["../../src/error-message.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { BaseError } from './base-error.interface';
2
+ export interface ErrorPayload extends BaseError {
3
+ /**
4
+ * standard HTTP status code
5
+ */
6
+ statusCode: number;
7
+ /**
8
+ * textual representation of HTTP status code
9
+ */
10
+ statusText: string;
11
+ /**
12
+ * message from the internal error that caused the error response
13
+ */
14
+ cause?: string;
15
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=error-payload.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-payload.interface.js","sourceRoot":"","sources":["../../src/error-payload.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ export declare const BadRequestException: import("./utils").HTTPExceptionClass;
2
+ export declare const UnauthorizedException: import("./utils").HTTPExceptionClass;
3
+ export declare const PaymentRequiredException: import("./utils").HTTPExceptionClass;
4
+ export declare const ForbiddenException: import("./utils").HTTPExceptionClass;
5
+ export declare const NotFoundException: import("./utils").HTTPExceptionClass;
6
+ export declare const MethodNotAllowedException: import("./utils").HTTPExceptionClass;
7
+ export declare const NotAcceptableException: import("./utils").HTTPExceptionClass;
8
+ export declare const ProxyAuthenticationRequiredException: import("./utils").HTTPExceptionClass;
9
+ export declare const RequestTimeoutException: import("./utils").HTTPExceptionClass;
10
+ export declare const ConflictException: import("./utils").HTTPExceptionClass;
11
+ export declare const GoneException: import("./utils").HTTPExceptionClass;
12
+ export declare const LengthRequiredException: import("./utils").HTTPExceptionClass;
13
+ export declare const PreconditionFailedException: import("./utils").HTTPExceptionClass;
14
+ export declare const PayloadTooLargeException: import("./utils").HTTPExceptionClass;
15
+ export declare const URITooLongException: import("./utils").HTTPExceptionClass;
16
+ export declare const UnsupportedMediaTypeException: import("./utils").HTTPExceptionClass;
17
+ export declare const RangeNotSatisfiableException: import("./utils").HTTPExceptionClass;
18
+ export declare const ExpectationFailedException: import("./utils").HTTPExceptionClass;
19
+ export declare const ImATeapotException: import("./utils").HTTPExceptionClass;
20
+ export declare const MisdirectedRequestException: import("./utils").HTTPExceptionClass;
21
+ export declare const UnprocessableEntityException: import("./utils").HTTPExceptionClass;
22
+ export declare const LockedException: import("./utils").HTTPExceptionClass;
23
+ export declare const FailedDependencyException: import("./utils").HTTPExceptionClass;
24
+ export declare const TooEarlyException: import("./utils").HTTPExceptionClass;
25
+ export declare const UpgradeRequiredException: import("./utils").HTTPExceptionClass;
26
+ export declare const PreconditionRequiredException: import("./utils").HTTPExceptionClass;
27
+ export declare const TooManyRequestsException: import("./utils").HTTPExceptionClass;
28
+ export declare const RequestHeaderFieldsTooLargeException: import("./utils").HTTPExceptionClass;
29
+ export declare const UnavailableForLegalReasonsException: import("./utils").HTTPExceptionClass;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnavailableForLegalReasonsException = exports.RequestHeaderFieldsTooLargeException = exports.TooManyRequestsException = exports.PreconditionRequiredException = exports.UpgradeRequiredException = exports.TooEarlyException = exports.FailedDependencyException = exports.LockedException = exports.UnprocessableEntityException = exports.MisdirectedRequestException = exports.ImATeapotException = exports.ExpectationFailedException = exports.RangeNotSatisfiableException = exports.UnsupportedMediaTypeException = exports.URITooLongException = exports.PayloadTooLargeException = exports.PreconditionFailedException = exports.LengthRequiredException = exports.GoneException = exports.ConflictException = exports.RequestTimeoutException = exports.ProxyAuthenticationRequiredException = exports.NotAcceptableException = exports.MethodNotAllowedException = exports.NotFoundException = exports.ForbiddenException = exports.PaymentRequiredException = exports.UnauthorizedException = exports.BadRequestException = void 0;
4
+ const http_status_enum_1 = require("./http-status.enum");
5
+ const utils_1 = require("./utils");
6
+ exports.BadRequestException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.BAD_REQUEST, 'Bad Request');
7
+ exports.UnauthorizedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.UNAUTHORIZED, 'Unauthorized');
8
+ exports.PaymentRequiredException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.PAYMENT_REQUIRED, 'Payment Required');
9
+ exports.ForbiddenException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.FORBIDDEN, 'Forbidden');
10
+ exports.NotFoundException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.NOT_FOUND, 'Not Found');
11
+ exports.MethodNotAllowedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.METHOD_NOT_ALLOWED, 'Method Not Allowed');
12
+ exports.NotAcceptableException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.NOT_ACCEPTABLE, 'Not Acceptable');
13
+ exports.ProxyAuthenticationRequiredException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.PROXY_AUTHENTICATION_REQUIRED, 'Proxy Authentication Required');
14
+ exports.RequestTimeoutException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.REQUEST_TIMEOUT, 'Request Timeout');
15
+ exports.ConflictException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.CONFLICT, 'Conflict');
16
+ exports.GoneException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.GONE, 'Gone');
17
+ exports.LengthRequiredException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.LENGTH_REQUIRED, 'Length Required');
18
+ exports.PreconditionFailedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.PRECONDITION_FAILED, 'Precondition Failed');
19
+ exports.PayloadTooLargeException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.PAYLOAD_TOO_LARGE, 'Payload Too Large');
20
+ exports.URITooLongException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.URI_TOO_LONG, 'URI Too Long');
21
+ exports.UnsupportedMediaTypeException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.UNSUPPORTED_MEDIA_TYPE, 'Unsupported Media Type');
22
+ exports.RangeNotSatisfiableException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.RANGE_NOT_SATISFIABLE, 'Range Not Satisfiable');
23
+ exports.ExpectationFailedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.EXPECTATION_FAILED, 'Expectation Failed');
24
+ exports.ImATeapotException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.I_AM_A_TEAPOT, "I'm a teapot");
25
+ exports.MisdirectedRequestException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.MISDIRECTED_REQUEST, 'Misdirected Request');
26
+ exports.UnprocessableEntityException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.UNPROCESSABLE_ENTITY, 'Unprocessable Entity');
27
+ exports.LockedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.LOCKED, 'Locked');
28
+ exports.FailedDependencyException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.FAILED_DEPENDENCY, 'Failed Dependency');
29
+ exports.TooEarlyException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.TOO_EARLY, 'Too Early');
30
+ exports.UpgradeRequiredException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.UPGRADE_REQUIRED, 'Upgrade Required');
31
+ exports.PreconditionRequiredException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.PRECONDITION_REQUIRED, 'Precondition Required');
32
+ exports.TooManyRequestsException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.TOO_MANY_REQUESTS, 'Too Many Requests');
33
+ exports.RequestHeaderFieldsTooLargeException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.REQUEST_HEADER_FIELDS_TOO_LARGE, 'Request Header Fields Too Large');
34
+ exports.UnavailableForLegalReasonsException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.UNAVAILABLE_FOR_LEGAL_REASONS, 'Unavailable For Legal Reasons');
35
+ //# sourceMappingURL=http-4xx.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-4xx.exception.js","sourceRoot":"","sources":["../../../src/http/http-4xx.exception.ts"],"names":[],"mappings":";;;AAAA,yDAAgD;AAChD,mCAA8C;AAEjC,QAAA,mBAAmB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AACjF,QAAA,qBAAqB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AACrF,QAAA,wBAAwB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AAChG,QAAA,kBAAkB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AA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B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;AACtG,QAAA,kBAAkB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AACnF,QAAA,2BAA2B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC;AACzG,QAAA,4BAA4B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,CAAC;AAC5G,QAAA,eAAe,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACnE,QAAA,yBAAyB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;AACnG,QAAA,iBAAiB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAC3E,QAAA,wBAAwB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AAChG,QAAA,6BAA6B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;AAC/G,QAAA,wBAAwB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;AAClG,QAAA,oCAAoC,GAAG,IAAA,2BAAmB,EACrE,6BAAU,CAAC,+BAA+B,EAC1C,iCAAiC,CAClC,CAAC;AACW,QAAA,mCAAmC,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,6BAA6B,EAAE,+BAA+B,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const InternalServerErrorException: import("./utils").HTTPExceptionClass;
2
+ export declare const NotImplementedException: import("./utils").HTTPExceptionClass;
3
+ export declare const BadGatewayException: import("./utils").HTTPExceptionClass;
4
+ export declare const ServiceUnavailableException: import("./utils").HTTPExceptionClass;
5
+ export declare const GatewayTimeoutException: import("./utils").HTTPExceptionClass;
6
+ export declare const HTTPVersionNotSupportedException: import("./utils").HTTPExceptionClass;
7
+ export declare const VariantAlsoNegotiatesException: import("./utils").HTTPExceptionClass;
8
+ export declare const InsufficientStorageException: import("./utils").HTTPExceptionClass;
9
+ export declare const LoopDetectedException: import("./utils").HTTPExceptionClass;
10
+ export declare const NotExtendedException: import("./utils").HTTPExceptionClass;
11
+ export declare const NetworkAuthenticationRequiredException: import("./utils").HTTPExceptionClass;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NetworkAuthenticationRequiredException = exports.NotExtendedException = exports.LoopDetectedException = exports.InsufficientStorageException = exports.VariantAlsoNegotiatesException = exports.HTTPVersionNotSupportedException = exports.GatewayTimeoutException = exports.ServiceUnavailableException = exports.BadGatewayException = exports.NotImplementedException = exports.InternalServerErrorException = void 0;
4
+ const http_status_enum_1 = require("./http-status.enum");
5
+ const utils_1 = require("./utils");
6
+ exports.InternalServerErrorException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.INTERNAL_SERVER_ERROR, 'Internal Server Error');
7
+ exports.NotImplementedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.NOT_IMPLEMENTED, 'Not Implemented');
8
+ exports.BadGatewayException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.BAD_GATEWAY, 'Bad Gateway');
9
+ exports.ServiceUnavailableException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.SERVICE_UNAVAILABLE, 'Service Unavailable');
10
+ exports.GatewayTimeoutException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.GATEWAY_TIMEOUT, 'Gateway Timeout');
11
+ exports.HTTPVersionNotSupportedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.HTTP_VERSION_NOT_SUPPORTED, 'HTTP Version Not Supported');
12
+ exports.VariantAlsoNegotiatesException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.VARIANT_ALSO_NEGOTIATES, 'Variant Also Negotiates');
13
+ exports.InsufficientStorageException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.INSUFFICIENT_STORAGE, 'Insufficient Storage');
14
+ exports.LoopDetectedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.LOOP_DETECTED, 'Loop Detected');
15
+ exports.NotExtendedException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.NOT_EXTENDED, 'Not Extended');
16
+ exports.NetworkAuthenticationRequiredException = (0, utils_1.createHTTPException)(http_status_enum_1.HTTPStatus.NETWORK_AUTHENTICATION_REQUIRED, 'Network Authentication Required');
17
+ //# sourceMappingURL=http-5xx.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-5xx.exception.js","sourceRoot":"","sources":["../../../src/http/http-5xx.exception.ts"],"names":[],"mappings":";;;AAAA,yDAAgD;AAChD,mCAA8C;AAEjC,QAAA,4BAA4B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;AAC9G,QAAA,uBAAuB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAC7F,QAAA,mBAAmB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AACjF,QAAA,2BAA2B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC;AACzG,QAAA,uBAAuB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAC7F,QAAA,gCAAgC,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,0BAA0B,EAAE,4BAA4B,CAAC,CAAC;AAC5H,QAAA,8BAA8B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,uBAAuB,EAAE,yBAAyB,CAAC,CAAC;AACpH,QAAA,4BAA4B,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,CAAC;AAC5G,QAAA,qBAAqB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;AACvF,QAAA,oBAAoB,GAAG,IAAA,2BAAmB,EAAC,6BAAU,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AACpF,QAAA,sCAAsC,GAAG,IAAA,2BAAmB,EACvE,6BAAU,CAAC,+BAA+B,EAC1C,iCAAiC,CAClC,CAAC"}
@@ -0,0 +1,42 @@
1
+ export declare enum HTTPStatus {
2
+ BAD_REQUEST = 400,
3
+ UNAUTHORIZED = 401,
4
+ PAYMENT_REQUIRED = 402,
5
+ FORBIDDEN = 403,
6
+ NOT_FOUND = 404,
7
+ METHOD_NOT_ALLOWED = 405,
8
+ NOT_ACCEPTABLE = 406,
9
+ PROXY_AUTHENTICATION_REQUIRED = 407,
10
+ REQUEST_TIMEOUT = 408,
11
+ CONFLICT = 409,
12
+ GONE = 410,
13
+ LENGTH_REQUIRED = 411,
14
+ PRECONDITION_FAILED = 412,
15
+ PAYLOAD_TOO_LARGE = 413,
16
+ URI_TOO_LONG = 414,
17
+ UNSUPPORTED_MEDIA_TYPE = 415,
18
+ RANGE_NOT_SATISFIABLE = 416,
19
+ EXPECTATION_FAILED = 417,
20
+ I_AM_A_TEAPOT = 418,
21
+ MISDIRECTED_REQUEST = 421,
22
+ UNPROCESSABLE_ENTITY = 422,
23
+ LOCKED = 423,
24
+ FAILED_DEPENDENCY = 424,
25
+ TOO_EARLY = 425,
26
+ UPGRADE_REQUIRED = 426,
27
+ PRECONDITION_REQUIRED = 428,
28
+ TOO_MANY_REQUESTS = 429,
29
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
30
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451,
31
+ INTERNAL_SERVER_ERROR = 500,
32
+ NOT_IMPLEMENTED = 501,
33
+ BAD_GATEWAY = 502,
34
+ SERVICE_UNAVAILABLE = 503,
35
+ GATEWAY_TIMEOUT = 504,
36
+ HTTP_VERSION_NOT_SUPPORTED = 505,
37
+ VARIANT_ALSO_NEGOTIATES = 506,
38
+ INSUFFICIENT_STORAGE = 507,
39
+ LOOP_DETECTED = 508,
40
+ NOT_EXTENDED = 510,
41
+ NETWORK_AUTHENTICATION_REQUIRED = 511
42
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTPStatus = void 0;
4
+ var HTTPStatus;
5
+ (function (HTTPStatus) {
6
+ /* 4xx */
7
+ HTTPStatus[HTTPStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
8
+ HTTPStatus[HTTPStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
9
+ HTTPStatus[HTTPStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
10
+ HTTPStatus[HTTPStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
11
+ HTTPStatus[HTTPStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
12
+ HTTPStatus[HTTPStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
13
+ HTTPStatus[HTTPStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
14
+ HTTPStatus[HTTPStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
15
+ HTTPStatus[HTTPStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
16
+ HTTPStatus[HTTPStatus["CONFLICT"] = 409] = "CONFLICT";
17
+ HTTPStatus[HTTPStatus["GONE"] = 410] = "GONE";
18
+ HTTPStatus[HTTPStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
19
+ HTTPStatus[HTTPStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
20
+ HTTPStatus[HTTPStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
21
+ HTTPStatus[HTTPStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
22
+ HTTPStatus[HTTPStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
23
+ HTTPStatus[HTTPStatus["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
24
+ HTTPStatus[HTTPStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
25
+ HTTPStatus[HTTPStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
26
+ HTTPStatus[HTTPStatus["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
27
+ HTTPStatus[HTTPStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
28
+ HTTPStatus[HTTPStatus["LOCKED"] = 423] = "LOCKED";
29
+ HTTPStatus[HTTPStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
30
+ HTTPStatus[HTTPStatus["TOO_EARLY"] = 425] = "TOO_EARLY";
31
+ HTTPStatus[HTTPStatus["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
32
+ HTTPStatus[HTTPStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
33
+ HTTPStatus[HTTPStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
34
+ HTTPStatus[HTTPStatus["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
35
+ HTTPStatus[HTTPStatus["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
36
+ /* 5xx */
37
+ HTTPStatus[HTTPStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
38
+ HTTPStatus[HTTPStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
39
+ HTTPStatus[HTTPStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
40
+ HTTPStatus[HTTPStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
41
+ HTTPStatus[HTTPStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
42
+ HTTPStatus[HTTPStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
43
+ HTTPStatus[HTTPStatus["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
44
+ HTTPStatus[HTTPStatus["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
45
+ HTTPStatus[HTTPStatus["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
46
+ HTTPStatus[HTTPStatus["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
47
+ HTTPStatus[HTTPStatus["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
48
+ })(HTTPStatus = exports.HTTPStatus || (exports.HTTPStatus = {}));
49
+ //# sourceMappingURL=http-status.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-status.enum.js","sourceRoot":"","sources":["../../../src/http/http-status.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,UA4CX;AA5CD,WAAY,UAAU;IACpB,SAAS;IACT,2DAAiB,CAAA;IACjB,6DAAkB,CAAA;IAClB,qEAAsB,CAAA;IACtB,uDAAe,CAAA;IACf,uDAAe,CAAA;IACf,yEAAwB,CAAA;IACxB,iEAAoB,CAAA;IACpB,+FAAmC,CAAA;IACnC,mEAAqB,CAAA;IACrB,qDAAc,CAAA;IACd,6CAAU,CAAA;IACV,mEAAqB,CAAA;IACrB,2EAAyB,CAAA;IACzB,uEAAuB,CAAA;IACvB,6DAAkB,CAAA;IAClB,iFAA4B,CAAA;IAC5B,+EAA2B,CAAA;IAC3B,yEAAwB,CAAA;IACxB,+DAAmB,CAAA;IACnB,2EAAyB,CAAA;IACzB,6EAA0B,CAAA;IAC1B,iDAAY,CAAA;IACZ,uEAAuB,CAAA;IACvB,uDAAe,CAAA;IACf,qEAAsB,CAAA;IACtB,+EAA2B,CAAA;IAC3B,uEAAuB,CAAA;IACvB,mGAAqC,CAAA;IACrC,+FAAmC,CAAA;IAEnC,SAAS;IACT,+EAA2B,CAAA;IAC3B,mEAAqB,CAAA;IACrB,2DAAiB,CAAA;IACjB,2EAAyB,CAAA;IACzB,mEAAqB,CAAA;IACrB,yFAAgC,CAAA;IAChC,mFAA6B,CAAA;IAC7B,6EAA0B,CAAA;IAC1B,+DAAmB,CAAA;IACnB,6DAAkB,CAAA;IAClB,mGAAqC,CAAA;AACvC,CAAC,EA5CW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QA4CrB"}
@@ -0,0 +1,11 @@
1
+ import { ErrorMessage } from "../error-message.interface";
2
+ import { ErrorPayload } from "../error-payload.interface";
3
+ import { InternalException } from "../internal.exception";
4
+ export declare class HTTPException extends InternalException {
5
+ static instanceOf(err: any): err is HTTPException;
6
+ statusCode: number;
7
+ statusText: string;
8
+ response: ErrorPayload;
9
+ constructor(statusCode: number, statusText: string, msg?: ErrorMessage);
10
+ createResponse(): ErrorPayload;
11
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTPException = void 0;
4
+ const internal_exception_1 = require("../internal.exception");
5
+ class HTTPException extends internal_exception_1.InternalException {
6
+ constructor(statusCode, statusText, msg = statusText) {
7
+ super(msg);
8
+ this.message || (this.message = statusText);
9
+ this.statusCode = statusCode;
10
+ this.statusText = statusText;
11
+ this.response = this.createResponse();
12
+ }
13
+ static instanceOf(err) {
14
+ return err instanceof HTTPException;
15
+ }
16
+ createResponse() {
17
+ const cause = this.getCause();
18
+ return Object.assign(Object.assign(Object.assign({ message: this.message, statusCode: this.statusCode, statusText: this.statusText }, (this.details && { details: this.details })), (this.errorCode && { errorCode: this.errorCode })), (cause && { cause }));
19
+ }
20
+ }
21
+ exports.HTTPException = HTTPException;
22
+ //# sourceMappingURL=http.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.exception.js","sourceRoot":"","sources":["../../../src/http/http.exception.ts"],"names":[],"mappings":";;;AAEA,8DAAkE;AAElE,MAAa,aAAc,SAAQ,sCAAiB;IAWlD,YAAY,UAAkB,EAAE,UAAkB,EAAE,MAAoB,UAAU;QAChF,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,OAAO,KAAZ,IAAI,CAAC,OAAO,GAAK,UAAU,EAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;IAhBM,MAAM,CAAC,UAAU,CAAC,GAAQ;QAC/B,OAAO,GAAG,YAAY,aAAa,CAAC;IACtC,CAAC;IAgBM,cAAc;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAE9B,mDACE,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,UAAU,EAAE,IAAI,CAAC,UAAU,IAExB,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,GAC3C,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,GACjD,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,CAAC,EACvB;IACJ,CAAC;CACF;AAhCD,sCAgCC"}
@@ -0,0 +1,7 @@
1
+ import { ErrorMessage } from "../error-message.interface";
2
+ import { HTTPException } from './http.exception';
3
+ import { HTTPStatus } from './http-status.enum';
4
+ export interface HTTPExceptionClass {
5
+ new (message?: ErrorMessage): HTTPException;
6
+ }
7
+ export declare const createHTTPException: (statusCode: HTTPStatus, statusText: string) => HTTPExceptionClass;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHTTPException = void 0;
4
+ const http_exception_1 = require("./http.exception");
5
+ const WHITESPACE_PATTERN = /\s+/g;
6
+ const createHTTPException = (statusCode, statusText) => {
7
+ class NamedHTTPException extends http_exception_1.HTTPException {
8
+ constructor(message) {
9
+ super(statusCode, statusText, message);
10
+ }
11
+ }
12
+ Object.defineProperty(NamedHTTPException, 'name', { value: `${statusText.replace(WHITESPACE_PATTERN, '')}Exception` });
13
+ return NamedHTTPException;
14
+ };
15
+ exports.createHTTPException = createHTTPException;
16
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/http/utils.ts"],"names":[],"mappings":";;;AAEA,qDAAiD;AAGjD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAM3B,MAAM,mBAAmB,GAAG,CAAC,UAAsB,EAAE,UAAkB,EAAsB,EAAE;IACpG,MAAM,kBAAmB,SAAQ,8BAAa;QAC5C,YAAY,OAAsB;YAChC,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAEvH,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAVW,QAAA,mBAAmB,uBAU9B"}
@@ -0,0 +1,22 @@
1
+ import { BaseError } from './base-error.interface';
2
+ import { ErrorCode } from './error-code.enum';
3
+ import { ErrorMessage } from './error-message.interface';
4
+ declare type UndefinedPartial<T> = {
5
+ [K in keyof T]?: T[K] | undefined;
6
+ };
7
+ export declare class InternalException extends Error implements BaseError {
8
+ static instanceOf(err: any): err is InternalException;
9
+ static extractData(msg?: ErrorMessage): InternalException.ErrorData;
10
+ name: string;
11
+ cause?: string | Error;
12
+ errorCode?: ErrorCode;
13
+ details?: object;
14
+ constructor(msg?: ErrorMessage);
15
+ getCause(): string | undefined;
16
+ }
17
+ export declare namespace InternalException {
18
+ interface ErrorData extends UndefinedPartial<BaseError> {
19
+ cause?: string | Error | undefined;
20
+ }
21
+ }
22
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InternalException = void 0;
4
+ const client_exception_1 = require("./client.exception");
5
+ const isObject = (value) => !!value && typeof value === 'object';
6
+ const hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
7
+ const isErrorLike = (error) => isObject(error) && hasProperty(error, 'message') && typeof error.message === 'string';
8
+ class InternalException extends Error {
9
+ constructor(msg) {
10
+ const data = InternalException.extractData(msg);
11
+ super(data.message);
12
+ this.name = this.constructor.name;
13
+ if (data.details)
14
+ this.details = data.details;
15
+ if (data.errorCode)
16
+ this.errorCode = data.errorCode;
17
+ if (data.cause)
18
+ this.cause = data.cause;
19
+ }
20
+ static instanceOf(err) {
21
+ return err instanceof InternalException;
22
+ }
23
+ static extractData(msg) {
24
+ let message;
25
+ let errorCode;
26
+ let details;
27
+ let cause;
28
+ if (typeof msg === 'string') {
29
+ message = msg;
30
+ }
31
+ else if (msg instanceof Error) {
32
+ cause = msg;
33
+ if (InternalException.instanceOf(msg) || client_exception_1.ClientException.instanceOf(msg)) {
34
+ details = msg.details;
35
+ errorCode = msg.errorCode;
36
+ }
37
+ }
38
+ else if (msg && typeof msg === 'object') {
39
+ message = msg.message;
40
+ details = msg.details;
41
+ errorCode = msg.errorCode;
42
+ if (msg.cause instanceof Error || typeof msg.cause === 'string') {
43
+ cause = msg.cause;
44
+ }
45
+ else if (isErrorLike(msg.cause)) {
46
+ cause = msg.cause.message;
47
+ }
48
+ }
49
+ return {
50
+ message,
51
+ details,
52
+ errorCode,
53
+ cause,
54
+ };
55
+ }
56
+ getCause() {
57
+ if (typeof this.cause === 'string')
58
+ return this.cause;
59
+ if (this.cause instanceof Error)
60
+ return this.cause.message;
61
+ return undefined;
62
+ }
63
+ }
64
+ exports.InternalException = InternalException;
65
+ //# sourceMappingURL=internal.exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.exception.js","sourceRoot":"","sources":["../../src/internal.exception.ts"],"names":[],"mappings":";;;AACA,yDAAqD;AAQrD,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC3F,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,GAAW,EAAsC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrI,MAAM,WAAW,GAAG,CAAC,KAAc,EAAgC,EAAE,CACnE,QAAQ,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AAExF,MAAa,iBAAkB,SAAQ,KAAK;IA8C1C,YAAY,GAAkB;QAC5B,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEhD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,IAAI,CAAC,OAAO;Y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O,CAAC;aAC3B;SACF;QAED,OAAO;YACL,OAAO;YACP,OAAO;YACP,SAAS;YACT,KAAK;SACN,CAAC;IACJ,CAAC;IAoBM,QAAQ;QACb,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QACtD,IAAI,IAAI,CAAC,KAAK,YAAY,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAC3D,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA7DD,8CA6DC"}
@@ -0,0 +1,10 @@
1
+ export * from './base-error.interface';
2
+ export * from './client.exception';
3
+ export * from './error-code.enum';
4
+ export * from './error-message.interface';
5
+ export * from './error-payload.interface';
6
+ export * from './http/http.exception';
7
+ export * from './http/http-4xx.exception';
8
+ export * from './http/http-5xx.exception';
9
+ export * from './http/http-status.enum';
10
+ export * from './internal.exception';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base-error.interface"), exports);
18
+ __exportStar(require("./client.exception"), exports);
19
+ __exportStar(require("./error-code.enum"), exports);
20
+ __exportStar(require("./error-message.interface"), exports);
21
+ __exportStar(require("./error-payload.interface"), exports);
22
+ __exportStar(require("./http/http.exception"), exports);
23
+ __exportStar(require("./http/http-4xx.exception"), exports);
24
+ __exportStar(require("./http/http-5xx.exception"), exports);
25
+ __exportStar(require("./http/http-status.enum"), exports);
26
+ __exportStar(require("./internal.exception"), exports);
27
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,qDAAmC;AACnC,oDAAkC;AAClC,4DAA0C;AAC1C,4DAA0C;AAC1C,wDAAsC;AACtC,4DAA0C;AAC1C,4DAA0C;AAC1C,0DAAwC;AACxC,uDAAqC"}