@voiceflow/exception 1.1.0 → 1.2.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.
- package/README.md +45 -0
- package/build/cjs/base-error.interface.d.ts +15 -0
- package/build/cjs/base-error.interface.js +3 -0
- package/build/cjs/base-error.interface.js.map +1 -0
- package/build/cjs/base-response.interface.d.ts +6 -0
- package/build/cjs/base-response.interface.js +3 -0
- package/build/cjs/base-response.interface.js.map +1 -0
- package/build/cjs/client.exception.d.ts +17 -0
- package/build/cjs/client.exception.js +42 -0
- package/build/cjs/client.exception.js.map +1 -0
- package/build/cjs/error-code.enum.d.ts +2 -0
- package/build/cjs/error-code.enum.js +7 -0
- package/build/cjs/error-code.enum.js.map +1 -0
- package/build/cjs/error-message.interface.d.ts +5 -0
- package/build/cjs/error-message.interface.js +3 -0
- package/build/cjs/error-message.interface.js.map +1 -0
- package/build/cjs/error-payload.interface.d.ts +15 -0
- package/build/cjs/error-payload.interface.js +3 -0
- package/build/cjs/error-payload.interface.js.map +1 -0
- package/build/cjs/http/http-4xx.exception.d.ts +29 -0
- package/build/cjs/http/http-4xx.exception.js +35 -0
- package/build/cjs/http/http-4xx.exception.js.map +1 -0
- package/build/cjs/http/http-5xx.exception.d.ts +11 -0
- package/build/cjs/http/http-5xx.exception.js +17 -0
- package/build/cjs/http/http-5xx.exception.js.map +1 -0
- package/build/cjs/http/http-status.enum.d.ts +42 -0
- package/build/cjs/http/http-status.enum.js +49 -0
- package/build/cjs/http/http-status.enum.js.map +1 -0
- package/build/cjs/http/http.exception.d.ts +11 -0
- package/build/cjs/http/http.exception.js +22 -0
- package/build/cjs/http/http.exception.js.map +1 -0
- package/build/cjs/http/utils.d.ts +7 -0
- package/build/cjs/http/utils.js +16 -0
- package/build/cjs/http/utils.js.map +1 -0
- package/build/cjs/internal.exception.d.ts +22 -0
- package/build/cjs/internal.exception.js +65 -0
- package/build/cjs/internal.exception.js.map +1 -0
- package/build/cjs/main.d.ts +11 -0
- package/build/cjs/main.js +28 -0
- package/build/cjs/main.js.map +1 -0
- package/build/esm/base-error.interface.d.ts +15 -0
- package/build/esm/base-error.interface.js +2 -0
- package/build/esm/base-error.interface.js.map +1 -0
- package/build/esm/base-response.interface.d.ts +6 -0
- package/build/esm/base-response.interface.js +2 -0
- package/build/esm/base-response.interface.js.map +1 -0
- package/build/esm/client.exception.d.ts +17 -0
- package/build/esm/client.exception.js +38 -0
- package/build/esm/client.exception.js.map +1 -0
- package/build/esm/error-code.enum.d.ts +2 -0
- package/build/esm/error-code.enum.js +4 -0
- package/build/esm/error-code.enum.js.map +1 -0
- package/build/esm/error-message.interface.d.ts +5 -0
- package/build/esm/error-message.interface.js +2 -0
- package/build/esm/error-message.interface.js.map +1 -0
- package/build/esm/error-payload.interface.d.ts +15 -0
- package/build/esm/error-payload.interface.js +2 -0
- package/build/esm/error-payload.interface.js.map +1 -0
- package/build/esm/http/http-4xx.exception.d.ts +29 -0
- package/build/esm/http/http-4xx.exception.js +32 -0
- package/build/esm/http/http-4xx.exception.js.map +1 -0
- package/build/esm/http/http-5xx.exception.d.ts +11 -0
- package/build/esm/http/http-5xx.exception.js +14 -0
- package/build/esm/http/http-5xx.exception.js.map +1 -0
- package/build/esm/http/http-status.enum.d.ts +42 -0
- package/build/esm/http/http-status.enum.js +46 -0
- package/build/esm/http/http-status.enum.js.map +1 -0
- package/build/esm/http/http.exception.d.ts +11 -0
- package/build/esm/http/http.exception.js +18 -0
- package/build/esm/http/http.exception.js.map +1 -0
- package/build/esm/http/utils.d.ts +7 -0
- package/build/esm/http/utils.js +12 -0
- package/build/esm/http/utils.js.map +1 -0
- package/build/esm/internal.exception.d.ts +22 -0
- package/build/esm/internal.exception.js +61 -0
- package/build/esm/internal.exception.js.map +1 -0
- package/build/esm/main.d.ts +11 -0
- package/build/esm/main.js +12 -0
- package/build/esm/main.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/tsconfig.esm.tsbuildinfo +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
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("./base-response.interface"), exports);
|
|
19
|
+
__exportStar(require("./client.exception"), exports);
|
|
20
|
+
__exportStar(require("./error-code.enum"), exports);
|
|
21
|
+
__exportStar(require("./error-message.interface"), exports);
|
|
22
|
+
__exportStar(require("./error-payload.interface"), exports);
|
|
23
|
+
__exportStar(require("./http/http.exception"), exports);
|
|
24
|
+
__exportStar(require("./http/http-4xx.exception"), exports);
|
|
25
|
+
__exportStar(require("./http/http-5xx.exception"), exports);
|
|
26
|
+
__exportStar(require("./http/http-status.enum"), exports);
|
|
27
|
+
__exportStar(require("./internal.exception"), exports);
|
|
28
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,4DAA0C;AAC1C,qDAAmC;AACnC,oDAAkC;AAClC,4DAA0C;AAC1C,4DAA0C;AAC1C,wDAAsC;AACtC,4DAA0C;AAC1C,4DAA0C;AAC1C,0DAAwC;AACxC,uDAAqC"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"base-error.interface.js","sourceRoot":"","sources":["../../src/base-error.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-response.interface.js","sourceRoot":"","sources":["../../src/base-response.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseResponse } from './base-response.interface';
|
|
2
|
+
import { ErrorCode } from './error-code.enum';
|
|
3
|
+
import { ErrorPayload } from './error-payload.interface';
|
|
4
|
+
export declare class ClientException<Res extends BaseResponse = BaseResponse> extends Error implements ErrorPayload {
|
|
5
|
+
static instanceOf(err: any): err is ClientException;
|
|
6
|
+
response: Res;
|
|
7
|
+
statusCode: number;
|
|
8
|
+
statusText: string;
|
|
9
|
+
errorCode?: ErrorCode;
|
|
10
|
+
cause?: string;
|
|
11
|
+
details?: object;
|
|
12
|
+
constructor(response: Res);
|
|
13
|
+
private extractDetailedError;
|
|
14
|
+
private extractOpaqueError;
|
|
15
|
+
getCause(): string | undefined;
|
|
16
|
+
build(): Promise<this>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export class ClientException extends Error {
|
|
2
|
+
constructor(response) {
|
|
3
|
+
super();
|
|
4
|
+
this.name = this.constructor.name;
|
|
5
|
+
this.response = response.clone();
|
|
6
|
+
this.statusCode = response.status;
|
|
7
|
+
this.statusText = response.statusText;
|
|
8
|
+
}
|
|
9
|
+
static instanceOf(err) {
|
|
10
|
+
return err instanceof ClientException;
|
|
11
|
+
}
|
|
12
|
+
extractDetailedError(body) {
|
|
13
|
+
this.message = body.message || this.response.statusText;
|
|
14
|
+
if (body.cause)
|
|
15
|
+
this.cause = body.cause;
|
|
16
|
+
if (body.details)
|
|
17
|
+
this.details = body.details;
|
|
18
|
+
if (body.errorCode)
|
|
19
|
+
this.errorCode = body.errorCode;
|
|
20
|
+
}
|
|
21
|
+
extractOpaqueError(text) {
|
|
22
|
+
this.message = text || this.response.statusText;
|
|
23
|
+
}
|
|
24
|
+
getCause() {
|
|
25
|
+
return this.cause;
|
|
26
|
+
}
|
|
27
|
+
async build() {
|
|
28
|
+
const text = await this.response.text();
|
|
29
|
+
try {
|
|
30
|
+
this.extractDetailedError(JSON.parse(text));
|
|
31
|
+
}
|
|
32
|
+
catch (_a) {
|
|
33
|
+
this.extractOpaqueError(text);
|
|
34
|
+
}
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=client.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.exception.js","sourceRoot":"","sources":["../../src/client.exception.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,eAAyD,SAAQ,KAAK;IAiBjF,YAAY,QAAa;QACvB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,UA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.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 @@
|
|
|
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,32 @@
|
|
|
1
|
+
import { HTTPStatus } from './http-status.enum';
|
|
2
|
+
import { createHTTPException } from './utils';
|
|
3
|
+
export const BadRequestException = createHTTPException(HTTPStatus.BAD_REQUEST, 'Bad Request');
|
|
4
|
+
export const UnauthorizedException = createHTTPException(HTTPStatus.UNAUTHORIZED, 'Unauthorized');
|
|
5
|
+
export const PaymentRequiredException = createHTTPException(HTTPStatus.PAYMENT_REQUIRED, 'Payment Required');
|
|
6
|
+
export const ForbiddenException = createHTTPException(HTTPStatus.FORBIDDEN, 'Forbidden');
|
|
7
|
+
export const NotFoundException = createHTTPException(HTTPStatus.NOT_FOUND, 'Not Found');
|
|
8
|
+
export const MethodNotAllowedException = createHTTPException(HTTPStatus.METHOD_NOT_ALLOWED, 'Method Not Allowed');
|
|
9
|
+
export const NotAcceptableException = createHTTPException(HTTPStatus.NOT_ACCEPTABLE, 'Not Acceptable');
|
|
10
|
+
export const ProxyAuthenticationRequiredException = createHTTPException(HTTPStatus.PROXY_AUTHENTICATION_REQUIRED, 'Proxy Authentication Required');
|
|
11
|
+
export const RequestTimeoutException = createHTTPException(HTTPStatus.REQUEST_TIMEOUT, 'Request Timeout');
|
|
12
|
+
export const ConflictException = createHTTPException(HTTPStatus.CONFLICT, 'Conflict');
|
|
13
|
+
export const GoneException = createHTTPException(HTTPStatus.GONE, 'Gone');
|
|
14
|
+
export const LengthRequiredException = createHTTPException(HTTPStatus.LENGTH_REQUIRED, 'Length Required');
|
|
15
|
+
export const PreconditionFailedException = createHTTPException(HTTPStatus.PRECONDITION_FAILED, 'Precondition Failed');
|
|
16
|
+
export const PayloadTooLargeException = createHTTPException(HTTPStatus.PAYLOAD_TOO_LARGE, 'Payload Too Large');
|
|
17
|
+
export const URITooLongException = createHTTPException(HTTPStatus.URI_TOO_LONG, 'URI Too Long');
|
|
18
|
+
export const UnsupportedMediaTypeException = createHTTPException(HTTPStatus.UNSUPPORTED_MEDIA_TYPE, 'Unsupported Media Type');
|
|
19
|
+
export const RangeNotSatisfiableException = createHTTPException(HTTPStatus.RANGE_NOT_SATISFIABLE, 'Range Not Satisfiable');
|
|
20
|
+
export const ExpectationFailedException = createHTTPException(HTTPStatus.EXPECTATION_FAILED, 'Expectation Failed');
|
|
21
|
+
export const ImATeapotException = createHTTPException(HTTPStatus.I_AM_A_TEAPOT, "I'm a teapot");
|
|
22
|
+
export const MisdirectedRequestException = createHTTPException(HTTPStatus.MISDIRECTED_REQUEST, 'Misdirected Request');
|
|
23
|
+
export const UnprocessableEntityException = createHTTPException(HTTPStatus.UNPROCESSABLE_ENTITY, 'Unprocessable Entity');
|
|
24
|
+
export const LockedException = createHTTPException(HTTPStatus.LOCKED, 'Locked');
|
|
25
|
+
export const FailedDependencyException = createHTTPException(HTTPStatus.FAILED_DEPENDENCY, 'Failed Dependency');
|
|
26
|
+
export const TooEarlyException = createHTTPException(HTTPStatus.TOO_EARLY, 'Too Early');
|
|
27
|
+
export const UpgradeRequiredException = createHTTPException(HTTPStatus.UPGRADE_REQUIRED, 'Upgrade Required');
|
|
28
|
+
export const PreconditionRequiredException = createHTTPException(HTTPStatus.PRECONDITION_REQUIRED, 'Precondition Required');
|
|
29
|
+
export const TooManyRequestsException = createHTTPException(HTTPStatus.TOO_MANY_REQUESTS, 'Too Many Requests');
|
|
30
|
+
export const RequestHeaderFieldsTooLargeException = createHTTPException(HTTPStatus.REQUEST_HEADER_FIELDS_TOO_LARGE, 'Request Header Fields Too Large');
|
|
31
|
+
export const UnavailableForLegalReasonsException = createHTTPException(HTTPStatus.UNAVAILABLE_FOR_LEGAL_REASONS, 'Unavailable For Legal Reasons');
|
|
32
|
+
//# 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,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,UAAU,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AAClG,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AAC7G,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,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
+
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,14 @@
|
|
|
1
|
+
import { HTTPStatus } from './http-status.enum';
|
|
2
|
+
import { createHTTPException } from './utils';
|
|
3
|
+
export const InternalServerErrorException = createHTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, 'Internal Server Error');
|
|
4
|
+
export const NotImplementedException = createHTTPException(HTTPStatus.NOT_IMPLEMENTED, 'Not Implemented');
|
|
5
|
+
export const BadGatewayException = createHTTPException(HTTPStatus.BAD_GATEWAY, 'Bad Gateway');
|
|
6
|
+
export const ServiceUnavailableException = createHTTPException(HTTPStatus.SERVICE_UNAVAILABLE, 'Service Unavailable');
|
|
7
|
+
export const GatewayTimeoutException = createHTTPException(HTTPStatus.GATEWAY_TIMEOUT, 'Gateway Timeout');
|
|
8
|
+
export const HTTPVersionNotSupportedException = createHTTPException(HTTPStatus.HTTP_VERSION_NOT_SUPPORTED, 'HTTP Version Not Supported');
|
|
9
|
+
export const VariantAlsoNegotiatesException = createHTTPException(HTTPStatus.VARIANT_ALSO_NEGOTIATES, 'Variant Also Negotiates');
|
|
10
|
+
export const InsufficientStorageException = createHTTPException(HTTPStatus.INSUFFICIENT_STORAGE, 'Insufficient Storage');
|
|
11
|
+
export const LoopDetectedException = createHTTPException(HTTPStatus.LOOP_DETECTED, 'Loop Detected');
|
|
12
|
+
export const NotExtendedException = createHTTPException(HTTPStatus.NOT_EXTENDED, 'Not Extended');
|
|
13
|
+
export const NetworkAuthenticationRequiredException = createHTTPException(HTTPStatus.NETWORK_AUTHENTICATION_REQUIRED, 'Network Authentication Required');
|
|
14
|
+
//# 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,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAC,UAAU,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;AAC3H,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC,UAAU,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC;AACtH,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,gCAAgC,GAAG,mBAAmB,CAAC,UAAU,CAAC,0BAA0B,EAAE,4BAA4B,CAAC,CAAC;AACzI,MAAM,CAAC,MAAM,8BAA8B,GAAG,mBAAmB,CAAC,UAAU,CAAC,uBAAuB,EAAE,yBAAyB,CAAC,CAAC;AACjI,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAC,UAAU,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,CAAC;AACzH,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;AACpG,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,UAAU,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,sCAAsC,GAAG,mBAAmB,CACvE,UAAU,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,46 @@
|
|
|
1
|
+
export var HTTPStatus;
|
|
2
|
+
(function (HTTPStatus) {
|
|
3
|
+
/* 4xx */
|
|
4
|
+
HTTPStatus[HTTPStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
5
|
+
HTTPStatus[HTTPStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
6
|
+
HTTPStatus[HTTPStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
7
|
+
HTTPStatus[HTTPStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
8
|
+
HTTPStatus[HTTPStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
9
|
+
HTTPStatus[HTTPStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
10
|
+
HTTPStatus[HTTPStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
11
|
+
HTTPStatus[HTTPStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
12
|
+
HTTPStatus[HTTPStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
13
|
+
HTTPStatus[HTTPStatus["CONFLICT"] = 409] = "CONFLICT";
|
|
14
|
+
HTTPStatus[HTTPStatus["GONE"] = 410] = "GONE";
|
|
15
|
+
HTTPStatus[HTTPStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
16
|
+
HTTPStatus[HTTPStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
17
|
+
HTTPStatus[HTTPStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
18
|
+
HTTPStatus[HTTPStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
19
|
+
HTTPStatus[HTTPStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
20
|
+
HTTPStatus[HTTPStatus["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
21
|
+
HTTPStatus[HTTPStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
22
|
+
HTTPStatus[HTTPStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
23
|
+
HTTPStatus[HTTPStatus["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
24
|
+
HTTPStatus[HTTPStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
25
|
+
HTTPStatus[HTTPStatus["LOCKED"] = 423] = "LOCKED";
|
|
26
|
+
HTTPStatus[HTTPStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
27
|
+
HTTPStatus[HTTPStatus["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
28
|
+
HTTPStatus[HTTPStatus["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
29
|
+
HTTPStatus[HTTPStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
30
|
+
HTTPStatus[HTTPStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
31
|
+
HTTPStatus[HTTPStatus["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
32
|
+
HTTPStatus[HTTPStatus["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
33
|
+
/* 5xx */
|
|
34
|
+
HTTPStatus[HTTPStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
35
|
+
HTTPStatus[HTTPStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
36
|
+
HTTPStatus[HTTPStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
37
|
+
HTTPStatus[HTTPStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
38
|
+
HTTPStatus[HTTPStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
39
|
+
HTTPStatus[HTTPStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
40
|
+
HTTPStatus[HTTPStatus["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
41
|
+
HTTPStatus[HTTPStatus["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
42
|
+
HTTPStatus[HTTPStatus["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
43
|
+
HTTPStatus[HTTPStatus["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
44
|
+
HTTPStatus[HTTPStatus["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
45
|
+
})(HTTPStatus || (HTTPStatus = {}));
|
|
46
|
+
//# 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,MAAM,CAAN,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,KAAV,UAAU,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,18 @@
|
|
|
1
|
+
import { InternalException } from "../internal.exception";
|
|
2
|
+
export class HTTPException extends InternalException {
|
|
3
|
+
constructor(statusCode, statusText, msg = statusText) {
|
|
4
|
+
super(msg);
|
|
5
|
+
this.message || (this.message = statusText);
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.statusText = statusText;
|
|
8
|
+
this.response = this.createResponse();
|
|
9
|
+
}
|
|
10
|
+
static instanceOf(err) {
|
|
11
|
+
return err instanceof HTTPException;
|
|
12
|
+
}
|
|
13
|
+
createResponse() {
|
|
14
|
+
const cause = this.getCause();
|
|
15
|
+
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 }));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# 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,OAAO,EAAE,iBAAiB,EAAE,8BAAsC;AAElE,MAAM,OAAO,aAAc,SAAQ,iBAAiB;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"}
|
|
@@ -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,12 @@
|
|
|
1
|
+
import { HTTPException } from './http.exception';
|
|
2
|
+
const WHITESPACE_PATTERN = /\s+/g;
|
|
3
|
+
export const createHTTPException = (statusCode, statusText) => {
|
|
4
|
+
class NamedHTTPException extends HTTPException {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(statusCode, statusText, message);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(NamedHTTPException, 'name', { value: `${statusText.replace(WHITESPACE_PATTERN, '')}Exception` });
|
|
10
|
+
return NamedHTTPException;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/http/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAMlC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,UAAsB,EAAE,UAAkB,EAAsB,EAAE;IACpG,MAAM,kBAAmB,SAAQ,aAAa;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"}
|
|
@@ -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,61 @@
|
|
|
1
|
+
import { ClientException } from './client.exception';
|
|
2
|
+
const isObject = (value) => !!value && typeof value === 'object';
|
|
3
|
+
const hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
4
|
+
const isErrorLike = (error) => isObject(error) && hasProperty(error, 'message') && typeof error.message === 'string';
|
|
5
|
+
export class InternalException extends Error {
|
|
6
|
+
constructor(msg) {
|
|
7
|
+
const data = InternalException.extractData(msg);
|
|
8
|
+
super(data.message);
|
|
9
|
+
this.name = this.constructor.name;
|
|
10
|
+
if (data.details)
|
|
11
|
+
this.details = data.details;
|
|
12
|
+
if (data.errorCode)
|
|
13
|
+
this.errorCode = data.errorCode;
|
|
14
|
+
if (data.cause)
|
|
15
|
+
this.cause = data.cause;
|
|
16
|
+
}
|
|
17
|
+
static instanceOf(err) {
|
|
18
|
+
return err instanceof InternalException;
|
|
19
|
+
}
|
|
20
|
+
static extractData(msg) {
|
|
21
|
+
let message;
|
|
22
|
+
let errorCode;
|
|
23
|
+
let details;
|
|
24
|
+
let cause;
|
|
25
|
+
if (typeof msg === 'string') {
|
|
26
|
+
message = msg;
|
|
27
|
+
}
|
|
28
|
+
else if (msg instanceof Error) {
|
|
29
|
+
cause = msg;
|
|
30
|
+
if (InternalException.instanceOf(msg) || ClientException.instanceOf(msg)) {
|
|
31
|
+
details = msg.details;
|
|
32
|
+
errorCode = msg.errorCode;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (msg && typeof msg === 'object') {
|
|
36
|
+
message = msg.message;
|
|
37
|
+
details = msg.details;
|
|
38
|
+
errorCode = msg.errorCode;
|
|
39
|
+
if (msg.cause instanceof Error || typeof msg.cause === 'string') {
|
|
40
|
+
cause = msg.cause;
|
|
41
|
+
}
|
|
42
|
+
else if (isErrorLike(msg.cause)) {
|
|
43
|
+
cause = msg.cause.message;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
message,
|
|
48
|
+
details,
|
|
49
|
+
errorCode,
|
|
50
|
+
cause,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
getCause() {
|
|
54
|
+
if (typeof this.cause === 'string')
|
|
55
|
+
return this.cause;
|
|
56
|
+
if (this.cause instanceof Error)
|
|
57
|
+
return this.cause.message;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=internal.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.exception.js","sourceRoot":"","sources":["../../src/internal.exception.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;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,MAAM,OAAO,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,CAA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AC,EAAE;gBACjC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './base-error.interface';
|
|
2
|
+
export * from './base-response.interface';
|
|
3
|
+
export * from './client.exception';
|
|
4
|
+
export * from './error-code.enum';
|
|
5
|
+
export * from './error-message.interface';
|
|
6
|
+
export * from './error-payload.interface';
|
|
7
|
+
export * from './http/http.exception';
|
|
8
|
+
export * from './http/http-4xx.exception';
|
|
9
|
+
export * from './http/http-5xx.exception';
|
|
10
|
+
export * from './http/http-status.enum';
|
|
11
|
+
export * from './internal.exception';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './base-error.interface';
|
|
2
|
+
export * from './base-response.interface';
|
|
3
|
+
export * from './client.exception';
|
|
4
|
+
export * from './error-code.enum';
|
|
5
|
+
export * from './error-message.interface';
|
|
6
|
+
export * from './error-payload.interface';
|
|
7
|
+
export * from './http/http.exception';
|
|
8
|
+
export * from './http/http-4xx.exception';
|
|
9
|
+
export * from './http/http-5xx.exception';
|
|
10
|
+
export * from './http/http-status.enum';
|
|
11
|
+
export * from './internal.exception';
|
|
12
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|