@tc-libs/error-handler 0.9.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.
Files changed (35) hide show
  1. package/README.md +11 -0
  2. package/package.json +12 -0
  3. package/src/constants/error.constant.d.ts +2 -0
  4. package/src/constants/error.constant.js +6 -0
  5. package/src/constants/error.constant.js.map +1 -0
  6. package/src/constants/index.d.ts +1 -0
  7. package/src/constants/index.js +5 -0
  8. package/src/constants/index.js.map +1 -0
  9. package/src/decorators/error.decorator.d.ts +1 -0
  10. package/src/decorators/error.decorator.js +9 -0
  11. package/src/decorators/error.decorator.js.map +1 -0
  12. package/src/decorators/index.d.ts +1 -0
  13. package/src/decorators/index.js +5 -0
  14. package/src/decorators/index.js.map +1 -0
  15. package/src/error-handler.module.d.ts +6 -0
  16. package/src/error-handler.module.js +48 -0
  17. package/src/error-handler.module.js.map +1 -0
  18. package/src/error-handler.module.options.d.ts +12 -0
  19. package/src/error-handler.module.options.js +5 -0
  20. package/src/error-handler.module.options.js.map +1 -0
  21. package/src/filters/error.http.filter.d.ts +16 -0
  22. package/src/filters/error.http.filter.js +146 -0
  23. package/src/filters/error.http.filter.js.map +1 -0
  24. package/src/filters/index.d.ts +1 -0
  25. package/src/filters/index.js +5 -0
  26. package/src/filters/index.js.map +1 -0
  27. package/src/guards/error.meta.guard.d.ts +7 -0
  28. package/src/guards/error.meta.guard.js +28 -0
  29. package/src/guards/error.meta.guard.js.map +1 -0
  30. package/src/guards/index.d.ts +1 -0
  31. package/src/guards/index.js +5 -0
  32. package/src/guards/index.js.map +1 -0
  33. package/src/index.d.ts +5 -0
  34. package/src/index.js +9 -0
  35. package/src/index.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # error-handler
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build error-handler` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test error-handler` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@tc-libs/error-handler",
3
+ "version": "0.9.0",
4
+ "dependencies": {
5
+ "tslib": "^2.3.0",
6
+ "@nestjs/common": "^10.0.2"
7
+ },
8
+ "type": "commonjs",
9
+ "main": "./src/index.js",
10
+ "typings": "./src/index.d.ts",
11
+ "types": "./src/index.d.ts"
12
+ }
@@ -0,0 +1,2 @@
1
+ export declare const ERROR_CLASS_META_KEY = "ErrorMetaClassKey";
2
+ export declare const ERROR_FUNCTION_META_KEY = "ErrorMetaFunctionKey";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERROR_FUNCTION_META_KEY = exports.ERROR_CLASS_META_KEY = void 0;
4
+ exports.ERROR_CLASS_META_KEY = 'ErrorMetaClassKey';
5
+ exports.ERROR_FUNCTION_META_KEY = 'ErrorMetaFunctionKey';
6
+ //# sourceMappingURL=error.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.constant.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/constants/error.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,mBAAmB,CAAC;AAC3C,QAAA,uBAAuB,GAAG,sBAAsB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './error.constant';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./error.constant"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/constants/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC"}
@@ -0,0 +1 @@
1
+ export declare function ErrorMeta(cls: string, func: string): MethodDecorator;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorMeta = ErrorMeta;
4
+ const common_1 = require("@nestjs/common");
5
+ const constants_1 = require("../constants");
6
+ function ErrorMeta(cls, func) {
7
+ return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(constants_1.ERROR_CLASS_META_KEY, cls), (0, common_1.SetMetadata)(constants_1.ERROR_FUNCTION_META_KEY, func));
8
+ }
9
+ //# sourceMappingURL=error.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.decorator.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/decorators/error.decorator.ts"],"names":[],"mappings":";;AAGA,8BAKC;AARD,2CAA8D;AAC9D,4CAA6E;AAE7E,SAAgB,SAAS,CAAC,GAAW,EAAE,IAAY;IACjD,OAAO,IAAA,wBAAe,EACpB,IAAA,oBAAW,EAAC,gCAAoB,EAAE,GAAG,CAAC,EACtC,IAAA,oBAAW,EAAC,mCAAuB,EAAE,IAAI,CAAC,CAC3C,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './error.decorator';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./error.decorator"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC"}
@@ -0,0 +1,6 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import ErrorHandlerModuleAsyncOptions, { ErrorHandlerModuleOptions } from './error-handler.module.options';
3
+ export declare class ErrorHandlerModule {
4
+ static register(options: ErrorHandlerModuleOptions, isGlobal?: boolean): DynamicModule;
5
+ static registerAsync(options: ErrorHandlerModuleAsyncOptions, isGlobal?: boolean): DynamicModule;
6
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorHandlerModule = void 0;
4
+ const core_1 = require("@nestjs/core");
5
+ const error_http_filter_1 = require("./filters/error.http.filter");
6
+ const error_meta_guard_1 = require("./guards/error.meta.guard");
7
+ const error_handler_module_options_1 = require("./error-handler.module.options");
8
+ const providers = [
9
+ {
10
+ provide: core_1.APP_FILTER,
11
+ useClass: error_http_filter_1.ErrorHttpFilter,
12
+ },
13
+ {
14
+ provide: core_1.APP_GUARD,
15
+ useClass: error_meta_guard_1.ErrorMetaGuard,
16
+ },
17
+ ];
18
+ class ErrorHandlerModule {
19
+ static register(options, isGlobal) {
20
+ return {
21
+ module: ErrorHandlerModule,
22
+ imports: [],
23
+ providers: [
24
+ { provide: error_handler_module_options_1.ERROR_HANDLER_CONFIG_OPTIONS, useValue: options },
25
+ ...providers,
26
+ ],
27
+ global: isGlobal,
28
+ };
29
+ }
30
+ static registerAsync(options, isGlobal) {
31
+ return {
32
+ module: ErrorHandlerModule,
33
+ imports: [...(options.imports || [])],
34
+ providers: [
35
+ {
36
+ provide: error_handler_module_options_1.ERROR_HANDLER_CONFIG_OPTIONS,
37
+ useFactory: options.useFactory,
38
+ inject: options.inject,
39
+ },
40
+ ...providers,
41
+ ],
42
+ exports: [],
43
+ global: isGlobal,
44
+ };
45
+ }
46
+ }
47
+ exports.ErrorHandlerModule = ErrorHandlerModule;
48
+ //# sourceMappingURL=error-handler.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.module.js","sourceRoot":"","sources":["../../../../packages/error-handler/src/error-handler.module.ts"],"names":[],"mappings":";;;AACA,uCAAqD;AACrD,mEAA8D;AAC9D,gEAA2D;AAC3D,iFAGwC;AACxC,MAAM,SAAS,GAAG;IAChB;QACE,OAAO,EAAE,iBAAU;QACnB,QAAQ,EAAE,mCAAe;KAC1B;IACD;QACE,OAAO,EAAE,gBAAS;QAClB,QAAQ,EAAE,iCAAc;KACzB;CACF,CAAC;AACF,MAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CACb,OAAkC,EAClC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,kBAAkB;YAC1B,OAAO,EAAE,EAAE;YACX,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,2DAA4B,EAAE,QAAQ,EAAE,OAAO,EAAE;gBAC5D,GAAG,SAAS;aACb;YACD,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,aAAa,CAClB,OAAuC,EACvC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,kBAAkB;YAC1B,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,2DAA4B;oBACrC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;gBACD,GAAG,SAAS;aACb;YACD,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;CACF;AAnCD,gDAmCC"}
@@ -0,0 +1,12 @@
1
+ import { ModuleMetadata } from '@nestjs/common';
2
+ import { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
3
+ export declare const ERROR_HANDLER_CONFIG_OPTIONS = "HELPER_CONFIG_OPTIONS";
4
+ export interface ErrorHandlerModuleOptions {
5
+ availableLanguages: string[];
6
+ versioning: {
7
+ version: string;
8
+ };
9
+ repoVersion: string;
10
+ }
11
+ type ErrorHandlerModuleAsyncOptions = Pick<ModuleMetadata, 'imports'> & Pick<FactoryProvider<ErrorHandlerModuleOptions>, 'useFactory' | 'inject'>;
12
+ export default ErrorHandlerModuleAsyncOptions;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERROR_HANDLER_CONFIG_OPTIONS = void 0;
4
+ exports.ERROR_HANDLER_CONFIG_OPTIONS = 'HELPER_CONFIG_OPTIONS';
5
+ //# sourceMappingURL=error-handler.module.options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.module.options.js","sourceRoot":"","sources":["../../../../packages/error-handler/src/error-handler.module.options.ts"],"names":[],"mappings":";;;AAGa,QAAA,4BAA4B,GAAG,uBAAuB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
+ import { MessageService } from '@tc-libs/message';
3
+ import { DebuggerService } from '@tc-libs/debugger';
4
+ import { IErrorException } from '@tc-libs/errors';
5
+ import { DateService } from '@tc-libs/helper';
6
+ import { ErrorHandlerModuleOptions } from '../error-handler.module.options';
7
+ export declare class ErrorHttpFilter implements ExceptionFilter {
8
+ private readonly _options;
9
+ private readonly debuggerService;
10
+ private readonly messageService;
11
+ private readonly helperDateService;
12
+ private readonly availableLanguages;
13
+ constructor(_options: ErrorHandlerModuleOptions, debuggerService: DebuggerService, messageService: MessageService, helperDateService: DateService);
14
+ catch(exception: unknown, host: ArgumentsHost): Promise<void>;
15
+ isErrorException(obj: any): obj is IErrorException;
16
+ }
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var ErrorHttpFilter_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ErrorHttpFilter = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const message_1 = require("@tc-libs/message");
8
+ // import { ErrorMetadataDto } from '../dtos/error.dto';
9
+ const debugger_1 = require("@tc-libs/debugger");
10
+ const errors_1 = require("@tc-libs/errors");
11
+ const helper_1 = require("@tc-libs/helper");
12
+ const uuid_1 = require("uuid");
13
+ const error_handler_module_options_1 = require("../error-handler.module.options");
14
+ const error_interface_1 = require("@tc-libs/error-interface");
15
+ // If we throw error with HttpException, there will always return object
16
+ // The exception filter only catch HttpException
17
+ let ErrorHttpFilter = ErrorHttpFilter_1 = class ErrorHttpFilter {
18
+ constructor(_options, debuggerService, messageService, helperDateService) {
19
+ this._options = _options;
20
+ this.debuggerService = debuggerService;
21
+ this.messageService = messageService;
22
+ this.helperDateService = helperDateService;
23
+ this.availableLanguages = this._options.availableLanguages;
24
+ }
25
+ async catch(exception, host) {
26
+ const ctx = host.switchToHttp();
27
+ const response = ctx.getResponse();
28
+ const request = ctx.getRequest();
29
+ // get request headers
30
+ const __customLang = request.__customLang ?? this.availableLanguages;
31
+ const __class = request.__class ?? ErrorHttpFilter_1.name;
32
+ const __function = request.__function ?? this.catch.name;
33
+ const __requestId = request.__id ?? (0, uuid_1.v4)();
34
+ const __path = request.path;
35
+ const __timestamp = request.__xTimestamp ??
36
+ request.__timestamp ??
37
+ this.helperDateService.timestamp();
38
+ const __timezone = request.__timezone ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
39
+ const __version = request.__version ?? this._options.versioning.version;
40
+ const __repoVersion = request.__repoVersion ?? this._options.repoVersion;
41
+ const description = exception instanceof errors_1.ApiError
42
+ ? exception.description
43
+ : exception instanceof Error
44
+ ? exception.message
45
+ : exception.toString();
46
+ let messagePath = exception instanceof errors_1.ApiError ? exception.type : '';
47
+ let data = exception instanceof errors_1.ApiError ? exception.data : '';
48
+ // set default
49
+ let statusHttp = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
50
+ let statusCode = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
51
+ let _error = undefined;
52
+ let hasToLog = true;
53
+ let errors = undefined;
54
+ // let messageProperties: IMessageOptionsProperties | undefined = undefined;
55
+ let metadata = {
56
+ languages: __customLang,
57
+ timestamp: __timestamp,
58
+ timezone: __timezone,
59
+ requestId: __requestId,
60
+ path: __path,
61
+ version: __version,
62
+ repoVersion: __repoVersion,
63
+ };
64
+ if (exception instanceof errors_1.ApiError) {
65
+ // Restructure
66
+ const responseException = exception.getResponse();
67
+ statusHttp = exception.getStatus();
68
+ statusCode = exception.internalStatusCode;
69
+ hasToLog = !!exception.hasToLogConsole;
70
+ if (this.isErrorException(responseException)) {
71
+ const { _metadata } = responseException;
72
+ statusCode = responseException.statusCode;
73
+ messagePath = responseException.message;
74
+ data = responseException.data || {};
75
+ // messageProperties = _metadata?.customProperty?.messageProperties;
76
+ delete _metadata?.customProperty;
77
+ metadata = {
78
+ ...metadata,
79
+ ..._metadata,
80
+ };
81
+ if ((responseException.errors?.length ?? 0) > 0) {
82
+ errors =
83
+ responseException._errorType === error_interface_1.ERROR_TYPE.IMPORT
84
+ ? await this.messageService.getImportErrorsMessage(responseException.errors, __customLang)
85
+ : await this.messageService.getRequestErrorsMessage(responseException.errors, __customLang);
86
+ }
87
+ if (!responseException._error) {
88
+ _error =
89
+ typeof responseException._error !== 'string'
90
+ ? JSON.stringify(responseException._error)
91
+ : responseException._error;
92
+ }
93
+ }
94
+ }
95
+ else if (exception instanceof common_1.NotFoundException) {
96
+ hasToLog = false;
97
+ }
98
+ const responseBody = {
99
+ statusCode,
100
+ errors,
101
+ _error,
102
+ _metadata: metadata,
103
+ data: { description, ...data },
104
+ message: messagePath,
105
+ };
106
+ // Debugger
107
+ try {
108
+ if (hasToLog)
109
+ this.debuggerService.errorHttp(request?.__id ? request.__id : ErrorHttpFilter_1.name, {
110
+ description,
111
+ class: __class ?? ErrorHttpFilter_1.name,
112
+ function: __function ?? this.catch.name,
113
+ path: __path,
114
+ data,
115
+ }, exception);
116
+ }
117
+ catch (err) {
118
+ console.error(err);
119
+ }
120
+ response
121
+ .setHeader('x-custom-lang', __customLang)
122
+ .setHeader('x-timestamp', __timestamp)
123
+ .setHeader('x-timezone', __timezone)
124
+ .setHeader('x-request-id', __requestId)
125
+ .setHeader('x-version', __version)
126
+ .setHeader('x-repo-version', __repoVersion)
127
+ .status(statusHttp)
128
+ .json(responseBody);
129
+ return;
130
+ }
131
+ isErrorException(obj) {
132
+ return typeof obj === 'object'
133
+ ? 'statusCode' in obj && 'message' in obj
134
+ : false;
135
+ }
136
+ };
137
+ exports.ErrorHttpFilter = ErrorHttpFilter;
138
+ exports.ErrorHttpFilter = ErrorHttpFilter = ErrorHttpFilter_1 = tslib_1.__decorate([
139
+ (0, common_1.Catch)(),
140
+ tslib_1.__param(0, (0, common_1.Inject)(error_handler_module_options_1.ERROR_HANDLER_CONFIG_OPTIONS)),
141
+ tslib_1.__param(1, (0, common_1.Optional)()),
142
+ tslib_1.__metadata("design:paramtypes", [Object, debugger_1.DebuggerService,
143
+ message_1.MessageService,
144
+ helper_1.DateService])
145
+ ], ErrorHttpFilter);
146
+ //# sourceMappingURL=error.http.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.http.filter.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/filters/error.http.filter.ts"],"names":[],"mappings":";;;;;AAAA,2CAQwB;AAExB,8CAAkD;AAIlD,wDAAwD;AACxD,gDAAoD;AACpD,4CAA4D;AAC5D,4CAA8C;AAE9C,+BAAoC;AACpC,kFAGyC;AACzC,8DAKkC;AAClC,wEAAwE;AACxE,gDAAgD;AAEzC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAG1B,YAEmB,QAAmC,EACvB,eAAgC,EAC5C,cAA8B,EAC9B,iBAA8B;QAH9B,aAAQ,GAAR,QAAQ,CAA2B;QACvB,oBAAe,GAAf,eAAe,CAAiB;QAC5C,mBAAc,GAAd,cAAc,CAAgB;QAC9B,sBAAiB,GAAjB,iBAAiB,CAAa;QAE/C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,SAAkB,EAAE,IAAmB;QACjD,MAAM,GAAG,GAAsB,IAAI,CAAC,YAAY,EAAE,CAAC;QACnD,MAAM,QAAQ,GAAa,GAAG,CAAC,WAAW,EAAY,CAAC;QACvD,MAAM,OAAO,GAAgB,GAAG,CAAC,UAAU,EAAe,CAAC;QAE3D,sBAAsB;QACtB,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,kBAAkB,CAAC;QAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,I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AAU,CAAC;aACnC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC;aACtC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC;aACjC,SAAS,CAAC,gBAAgB,EAAE,aAAa,CAAC;aAC1C,MAAM,CAAC,UAAU,CAAC;aAClB,IAAI,CAAC,YAAY,CAAC,CAAC;QAEtB,OAAO;IACT,CAAC;IAED,gBAAgB,CAAC,GAAQ;QACvB,OAAO,OAAO,GAAG,KAAK,QAAQ;YAC5B,CAAC,CAAC,YAAY,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG;YACzC,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC;CACF,CAAA;AAtJY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,cAAK,GAAE;IAKH,mBAAA,IAAA,eAAM,EAAC,2DAA4B,CAAC,CAAA;IAEpC,mBAAA,IAAA,iBAAQ,GAAE,CAAA;qDAAmC,0BAAe;QAC5B,wBAAc;QACX,oBAAW;GARtC,eAAe,CAsJ3B"}
@@ -0,0 +1 @@
1
+ export * from './error.http.filter';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./error.http.filter"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/filters/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC"}
@@ -0,0 +1,7 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ export declare class ErrorMetaGuard implements CanActivate {
4
+ private readonly reflector;
5
+ constructor(reflector: Reflector);
6
+ canActivate(context: ExecutionContext): Promise<boolean>;
7
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorMetaGuard = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const core_1 = require("@nestjs/core");
7
+ const constants_1 = require("../constants");
8
+ let ErrorMetaGuard = class ErrorMetaGuard {
9
+ constructor(reflector) {
10
+ this.reflector = reflector;
11
+ }
12
+ async canActivate(context) {
13
+ const request = context.switchToHttp().getRequest();
14
+ const cls = this.reflector.get(constants_1.ERROR_CLASS_META_KEY, context.getHandler());
15
+ const func = this.reflector.get(constants_1.ERROR_FUNCTION_META_KEY, context.getHandler());
16
+ const className = context.getClass().name;
17
+ const methodKey = context.getHandler().name;
18
+ request.__class = cls ?? className;
19
+ request.__function = func ?? methodKey;
20
+ return true;
21
+ }
22
+ };
23
+ exports.ErrorMetaGuard = ErrorMetaGuard;
24
+ exports.ErrorMetaGuard = ErrorMetaGuard = tslib_1.__decorate([
25
+ (0, common_1.Injectable)(),
26
+ tslib_1.__metadata("design:paramtypes", [core_1.Reflector])
27
+ ], ErrorMetaGuard);
28
+ //# sourceMappingURL=error.meta.guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.meta.guard.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/guards/error.meta.guard.ts"],"names":[],"mappings":";;;;AAAA,2CAA2E;AAC3E,uCAAyC;AACzC,4CAA6E;AAGtE,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAC5B,gCAAoB,EACpB,OAAO,CAAC,UAAU,EAAE,CACrB,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAC7B,mCAAuB,EACvB,OAAO,CAAC,UAAU,EAAE,CACrB,CAAC;QAEF,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC;QAE5C,OAAO,CAAC,OAAO,GAAG,GAAG,IAAI,SAAS,CAAC;QACnC,OAAO,CAAC,UAAU,GAAG,IAAI,IAAI,SAAS,CAAC;QAEvC,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAtBY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;6CAE6B,gBAAS;GADtC,cAAc,CAsB1B"}
@@ -0,0 +1 @@
1
+ export * from './error.meta.guard';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./error.meta.guard"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/error-handler/src/guards/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './filters';
2
+ export * from './guards';
3
+ export * from './decorators';
4
+ export * from './error-handler.module';
5
+ export * from './constants';
package/src/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./filters"), exports);
5
+ tslib_1.__exportStar(require("./guards"), exports);
6
+ tslib_1.__exportStar(require("./decorators"), exports);
7
+ tslib_1.__exportStar(require("./error-handler.module"), exports);
8
+ tslib_1.__exportStar(require("./constants"), exports);
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/error-handler/src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,mDAAyB;AACzB,uDAA6B;AAC7B,iEAAuC;AACvC,sDAA4B"}