@volontariapp/errors-nest 0.5.0 → 0.6.2
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Type } from '@nestjs/common';
|
|
2
|
+
import type { BaseError } from '@volontariapp/errors';
|
|
2
3
|
import { ErrorResponseDto } from './error-response.dto.js';
|
|
3
4
|
export interface ApiErrorOptions {
|
|
4
5
|
description?: string;
|
|
@@ -16,4 +17,5 @@ export declare const ApiInternalServerErrorResponse: (options?: string | ApiErro
|
|
|
16
17
|
export declare const ApiConflictResponse: (options?: string | ApiErrorOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
17
18
|
export declare const ApiUnprocessableEntityResponse: (options?: string | ApiErrorOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
18
19
|
export declare const ApiTooManyRequestsResponse: (options?: string | ApiErrorOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
20
|
+
export declare function CustomApiError(errorFactory: (...args: unknown[]) => BaseError, options?: ApiErrorOptions): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
19
21
|
//# sourceMappingURL=api-error.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-error.decorator.d.ts","sourceRoot":"","sources":["../../src/swagger/api-error.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"api-error.decorator.d.ts","sourceRoot":"","sources":["../../src/swagger/api-error.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,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flictResponse = createErrorDecorator(ConflictError);
|
|
53
53
|
export const ApiUnprocessableEntityResponse = createErrorDecorator(UnprocessableEntityError);
|
|
54
54
|
export const ApiTooManyRequestsResponse = createErrorDecorator(TooManyRequestsError);
|
|
55
|
+
export function CustomApiError(errorFactory, options) {
|
|
56
|
+
const error = errorFactory();
|
|
57
|
+
const description = options?.description ?? error.message;
|
|
58
|
+
return ApiErrorResponse({
|
|
59
|
+
status: error.statusCode,
|
|
60
|
+
description,
|
|
61
|
+
example: options?.example,
|
|
62
|
+
type: options?.type,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
55
65
|
//# sourceMappingURL=api-error.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-error.decorator.js","sourceRoot":"","sources":["../../src/swagger/api-error.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQ3D,MAAM,UAAU,gBAAgB,CAC9B,OAEmB;IAEnB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAE1E,MAAM,eAAe,GAAuB;QAC1C,MAAM;QACN,WAAW,EAAE,WAAW,IAAI,SAAS,MAAM,CAAC,QAAQ,EAAE,EAAE;KACzD,CAAC;IAEF,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG;YAClB,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,WAAW,IAAI,mBAAmB;YAC3C,SAAS,EA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oBAAoB,CAAC,cAAc,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,8BAA8B,GAAG,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,8BAA8B,GAAG,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;AAC7F,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;AAErF,MAAM,UAAU,cAAc,CAC5B,YAA+C,EAC/C,OAAyB;IAEzB,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC;IAE1D,OAAO,gBAAgB,CAAC;QACtB,MAAM,EAAE,KAAK,CAAC,UAAU;QACxB,WAAW;QACX,OAAO,EAAE,OAAO,EAAE,OAAO;QACzB,IAAI,EAAE,OAAO,EAAE,IAAI;KACpB,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volontariapp/errors-nest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "5.7.3"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@volontariapp/errors": "0.4.
|
|
49
|
-
"@volontariapp/logger": "0.2.
|
|
48
|
+
"@volontariapp/errors": "0.4.2",
|
|
49
|
+
"@volontariapp/logger": "0.2.2",
|
|
50
50
|
"reflect-metadata": "^0.2.2",
|
|
51
51
|
"rxjs": "^7.8.1"
|
|
52
52
|
},
|