nestjs-exception-handler 4.0.0 → 4.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/dist/index.mjs ADDED
@@ -0,0 +1,520 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+
13
+ // src/formatters/prisma-exception.formatter.ts
14
+ import { Injectable } from "@nestjs/common";
15
+ import {
16
+ PrismaClientKnownRequestError,
17
+ PrismaClientValidationError,
18
+ PrismaClientRustPanicError,
19
+ PrismaClientInitializationError
20
+ } from "@prisma/client/runtime/library";
21
+ var PrismaExceptionFormatter = class {
22
+ supports(exception) {
23
+ return exception instanceof PrismaClientKnownRequestError || exception instanceof PrismaClientValidationError || exception instanceof PrismaClientRustPanicError || exception instanceof PrismaClientInitializationError;
24
+ }
25
+ format(exception) {
26
+ return this.formatError(exception);
27
+ }
28
+ message(_exception) {
29
+ return "Database error";
30
+ }
31
+ formatError(exception) {
32
+ if (exception instanceof PrismaClientKnownRequestError) {
33
+ return this.formatPrismaError(exception);
34
+ }
35
+ if (exception instanceof PrismaClientValidationError || exception instanceof PrismaClientRustPanicError) {
36
+ return this.formatQueryError(exception);
37
+ }
38
+ if (exception instanceof PrismaClientInitializationError) {
39
+ return this.formatInitializationError(exception);
40
+ }
41
+ return this.formatUnknownError(exception);
42
+ }
43
+ formatPrismaError(exception) {
44
+ const code = exception.code;
45
+ const meta = exception.meta;
46
+ switch (code) {
47
+ case "P2002": {
48
+ const target = meta?.target;
49
+ const field = target?.[0] || "field";
50
+ return [
51
+ {
52
+ path: field,
53
+ message: `A record with this ${field} already exists.`
54
+ }
55
+ ];
56
+ }
57
+ case "P2003": {
58
+ const fieldName = meta?.field_name;
59
+ return [
60
+ {
61
+ path: fieldName || "field",
62
+ message: `The referenced ${fieldName || "record"} does not exist.`
63
+ }
64
+ ];
65
+ }
66
+ case "P2005": {
67
+ const fieldName = meta?.field_name;
68
+ return [
69
+ {
70
+ path: fieldName || "field",
71
+ message: `The value for ${fieldName || "field"} is invalid.`
72
+ }
73
+ ];
74
+ }
75
+ case "P2006": {
76
+ const fieldName = meta?.field_name;
77
+ return [
78
+ {
79
+ path: fieldName || "field",
80
+ message: `The ${fieldName || "field"} field is required.`
81
+ }
82
+ ];
83
+ }
84
+ case "P2025": {
85
+ return [
86
+ {
87
+ path: "record",
88
+ message: "The requested record does not exist."
89
+ }
90
+ ];
91
+ }
92
+ default:
93
+ return [
94
+ {
95
+ path: "database",
96
+ message: "Database operation failed."
97
+ }
98
+ ];
99
+ }
100
+ }
101
+ formatQueryError(exception) {
102
+ let message = "Invalid database query.";
103
+ if (exception instanceof PrismaClientRustPanicError) {
104
+ message = "Database engine panic occurred.";
105
+ }
106
+ return [
107
+ {
108
+ path: "database",
109
+ message
110
+ }
111
+ ];
112
+ }
113
+ formatInitializationError(exception) {
114
+ return [
115
+ {
116
+ path: "database",
117
+ message: `Database initialization error: ${exception.message}`
118
+ }
119
+ ];
120
+ }
121
+ formatUnknownError(exception) {
122
+ return [
123
+ {
124
+ path: "unknown",
125
+ message: exception instanceof Error ? exception.message : "An unexpected database error occurred."
126
+ }
127
+ ];
128
+ }
129
+ };
130
+ PrismaExceptionFormatter = __decorateClass([
131
+ Injectable()
132
+ ], PrismaExceptionFormatter);
133
+
134
+ // src/formatters/dto-validation.formatter.ts
135
+ import { Injectable as Injectable2 } from "@nestjs/common";
136
+ var DtoValidationFormatter = class {
137
+ formatDtoValidationException(exception) {
138
+ const responseBody = exception.getResponse();
139
+ if (typeof responseBody === "object" && responseBody !== null && "message" in responseBody && Array.isArray(responseBody.message)) {
140
+ const messages = responseBody.message;
141
+ const firstMessage = messages[0];
142
+ if (firstMessage && typeof firstMessage === "object" && firstMessage !== null && "property" in firstMessage) {
143
+ const validationErrors = messages;
144
+ return validationErrors.map((error) => ({
145
+ path: error.property,
146
+ message: error.constraints ? Object.values(error.constraints).join(", ") : "Validation error"
147
+ }));
148
+ }
149
+ }
150
+ return [
151
+ {
152
+ path: "http_error",
153
+ message: typeof responseBody === "object" && responseBody !== null && "message" in responseBody ? String(responseBody.message) : "An HTTP error occurred"
154
+ }
155
+ ];
156
+ }
157
+ };
158
+ DtoValidationFormatter = __decorateClass([
159
+ Injectable2()
160
+ ], DtoValidationFormatter);
161
+
162
+ // src/formatters/other-exception.formatter.ts
163
+ import { Injectable as Injectable3 } from "@nestjs/common";
164
+ var OtherExceptionFormatter = class {
165
+ formatOtherError(exception) {
166
+ if (exception && typeof exception === "object" && "path" in exception && "message" in exception) {
167
+ return [
168
+ {
169
+ path: String(exception.path),
170
+ message: String(exception.message)
171
+ }
172
+ ];
173
+ }
174
+ const message = exception && typeof exception === "object" && "message" in exception ? String(exception.message) : "An unexpected error occurred";
175
+ return [
176
+ {
177
+ path: "unknown",
178
+ message
179
+ }
180
+ ];
181
+ }
182
+ };
183
+ OtherExceptionFormatter = __decorateClass([
184
+ Injectable3()
185
+ ], OtherExceptionFormatter);
186
+
187
+ // src/exception-filter/global-exception.filter.ts
188
+ import {
189
+ Catch,
190
+ HttpException,
191
+ HttpStatus,
192
+ Logger
193
+ } from "@nestjs/common";
194
+ import {
195
+ PrismaClientKnownRequestError as PrismaClientKnownRequestError2,
196
+ PrismaClientValidationError as PrismaClientValidationError2,
197
+ PrismaClientRustPanicError as PrismaClientRustPanicError2,
198
+ PrismaClientUnknownRequestError,
199
+ PrismaClientInitializationError as PrismaClientInitializationError2
200
+ } from "@prisma/client/runtime/library";
201
+ var GlobalExceptionFilter = class {
202
+ constructor(prismaExceptionFormatter, dtoValidationFormatter, otherValidationFormatter) {
203
+ this.prismaExceptionFormatter = prismaExceptionFormatter;
204
+ this.dtoValidationFormatter = dtoValidationFormatter;
205
+ this.otherValidationFormatter = otherValidationFormatter;
206
+ this.logger = new Logger(GlobalExceptionFilter.name);
207
+ }
208
+ getErrorMessage(exception) {
209
+ if (exception instanceof PrismaClientKnownRequestError2 || exception instanceof PrismaClientValidationError2 || exception instanceof PrismaClientRustPanicError2 || exception instanceof PrismaClientUnknownRequestError || exception instanceof PrismaClientInitializationError2) {
210
+ return "Database error";
211
+ }
212
+ if (exception instanceof HttpException) {
213
+ return exception.message || "HTTP error";
214
+ }
215
+ return "Internal server error";
216
+ }
217
+ catch(exception, host) {
218
+ const ctx = host.switchToHttp();
219
+ const response = ctx.getResponse();
220
+ const request = ctx.getRequest();
221
+ const status = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
222
+ let errorMessages = [{ path: "unknown", message: "Internal server error" }];
223
+ if (exception instanceof PrismaClientKnownRequestError2 || exception instanceof PrismaClientValidationError2 || exception instanceof PrismaClientRustPanicError2 || exception instanceof PrismaClientUnknownRequestError || exception instanceof PrismaClientInitializationError2) {
224
+ errorMessages = this.prismaExceptionFormatter.formatError(exception);
225
+ } else if (exception instanceof HttpException) {
226
+ errorMessages = this.dtoValidationFormatter.formatDtoValidationException(
227
+ exception
228
+ );
229
+ } else {
230
+ errorMessages = this.otherValidationFormatter.formatOtherError(exception);
231
+ }
232
+ this.logger.error(
233
+ `${request.method} ${request.url}`,
234
+ JSON.stringify(errorMessages),
235
+ "ExceptionFilter"
236
+ );
237
+ response.status(status).json({
238
+ success: false,
239
+ message: this.getErrorMessage(exception),
240
+ errorMessages
241
+ });
242
+ }
243
+ };
244
+ GlobalExceptionFilter = __decorateClass([
245
+ Catch()
246
+ ], GlobalExceptionFilter);
247
+
248
+ // src/module/exception-handler.module.ts
249
+ import { Module } from "@nestjs/common";
250
+
251
+ // src/services/exception-handler.service.ts
252
+ import { Injectable as Injectable4 } from "@nestjs/common";
253
+
254
+ // src/constants/default-messages.ts
255
+ var DEFAULT_PATH = "unknown";
256
+
257
+ // src/formatters/unknown-exception.formatter.ts
258
+ var UnknownExceptionFormatter = class {
259
+ supports(_exception) {
260
+ return true;
261
+ }
262
+ format(_exception) {
263
+ return [
264
+ {
265
+ path: DEFAULT_PATH,
266
+ message: "Internal server error"
267
+ }
268
+ ];
269
+ }
270
+ message(_exception) {
271
+ return "Internal server error";
272
+ }
273
+ };
274
+
275
+ // src/services/exception-handler.service.ts
276
+ var ExceptionHandlerService = class {
277
+ constructor() {
278
+ this.formatters = [];
279
+ this.defaultFormatter = new UnknownExceptionFormatter();
280
+ }
281
+ registerFormatter(formatter) {
282
+ this.formatters.push(formatter);
283
+ }
284
+ getFormatter(exception) {
285
+ for (const formatter of this.formatters) {
286
+ if (formatter.supports(exception)) {
287
+ return formatter;
288
+ }
289
+ }
290
+ return this.defaultFormatter;
291
+ }
292
+ formatException(exception) {
293
+ const formatter = this.getFormatter(exception);
294
+ const errors = formatter.format(exception);
295
+ const message = formatter.message(exception);
296
+ return { errors, message };
297
+ }
298
+ formatErrors(exception) {
299
+ const formatter = this.getFormatter(exception);
300
+ return formatter.format(exception);
301
+ }
302
+ getErrorMessage(exception) {
303
+ const formatter = this.getFormatter(exception);
304
+ return formatter.message(exception);
305
+ }
306
+ getAllFormatters() {
307
+ return [...this.formatters];
308
+ }
309
+ };
310
+ ExceptionHandlerService = __decorateClass([
311
+ Injectable4()
312
+ ], ExceptionHandlerService);
313
+
314
+ // src/filter/global-exception.filter.ts
315
+ import {
316
+ Catch as Catch2,
317
+ HttpException as HttpException2,
318
+ HttpStatus as HttpStatus2,
319
+ Logger as Logger2
320
+ } from "@nestjs/common";
321
+ var GlobalExceptionFilter2 = class {
322
+ constructor(exceptionHandlerService, config) {
323
+ this.exceptionHandlerService = exceptionHandlerService;
324
+ this.logger = new Logger2(GlobalExceptionFilter2.name);
325
+ this.config = config || { enableLogging: true, hideStackTrace: false };
326
+ }
327
+ catch(exception, host) {
328
+ const ctx = host.switchToHttp();
329
+ const response = ctx.getResponse();
330
+ const request = ctx.getRequest();
331
+ const { errors, message } = this.exceptionHandlerService.formatException(exception);
332
+ const status = this.getStatusCode(exception);
333
+ const errorResponse = {
334
+ success: false,
335
+ message,
336
+ errorMessages: errors
337
+ };
338
+ if (this.config.enableLogging) {
339
+ this.logError(request, status, errors, exception);
340
+ }
341
+ response.status(status).json(errorResponse);
342
+ }
343
+ getStatusCode(exception) {
344
+ if (exception instanceof HttpException2) {
345
+ return exception.getStatus();
346
+ }
347
+ return HttpStatus2.INTERNAL_SERVER_ERROR;
348
+ }
349
+ logError(request, status, errorMessages, exception) {
350
+ const method = request.method;
351
+ const url = request.url;
352
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
353
+ const logData = {
354
+ timestamp,
355
+ method,
356
+ url,
357
+ status,
358
+ errorMessages,
359
+ stack: this.config.hideStackTrace ? void 0 : exception?.stack
360
+ };
361
+ this.logger.error(`${method} ${url} - ${status}`, JSON.stringify(logData));
362
+ }
363
+ };
364
+ GlobalExceptionFilter2 = __decorateClass([
365
+ Catch2()
366
+ ], GlobalExceptionFilter2);
367
+
368
+ // src/formatters/dto-exception.formatter.ts
369
+ var DtoExceptionFormatter = class {
370
+ supports(exception) {
371
+ if (!exception || typeof exception !== "object") {
372
+ return false;
373
+ }
374
+ const error = exception;
375
+ return Array.isArray(error.validationErrors) || Array.isArray(error.children) && error.constraints !== void 0;
376
+ }
377
+ format(exception) {
378
+ const error = exception;
379
+ const validationErrors = error.validationErrors;
380
+ const children = error.children;
381
+ if (validationErrors) {
382
+ return this.formatValidationErrors(validationErrors);
383
+ }
384
+ if (children) {
385
+ return this.formatChildrenErrors(children);
386
+ }
387
+ return [{ path: "unknown", message: "Validation failed" }];
388
+ }
389
+ message(exception) {
390
+ const error = exception;
391
+ const validationErrors = error.validationErrors;
392
+ const children = error.children;
393
+ if (validationErrors && validationErrors.length > 0) {
394
+ const firstError = validationErrors[0];
395
+ const constraints = firstError.constraints;
396
+ if (constraints) {
397
+ return Object.values(constraints)[0];
398
+ }
399
+ }
400
+ if (children && children.length > 0) {
401
+ return "Validation failed for nested fields";
402
+ }
403
+ return "Validation failed";
404
+ }
405
+ formatValidationErrors(errors) {
406
+ return errors.flatMap((error) => {
407
+ const constraints = error.constraints;
408
+ if (constraints) {
409
+ return Object.entries(constraints).map(([, value]) => ({
410
+ path: error.property,
411
+ message: value
412
+ }));
413
+ }
414
+ return [];
415
+ });
416
+ }
417
+ formatChildrenErrors(children) {
418
+ return children.flatMap((child) => {
419
+ const constraints = child.constraints;
420
+ if (constraints) {
421
+ return Object.entries(constraints).map(([, value]) => ({
422
+ path: child.property,
423
+ message: value
424
+ }));
425
+ }
426
+ return [];
427
+ });
428
+ }
429
+ };
430
+
431
+ // src/formatters/http-exception.formatter.ts
432
+ import { HttpException as HttpException3 } from "@nestjs/common";
433
+ var HttpExceptionFormatter = class {
434
+ supports(exception) {
435
+ return exception instanceof HttpException3;
436
+ }
437
+ format(exception) {
438
+ const httpException = exception;
439
+ const response = httpException.getResponse();
440
+ if (typeof response === "string") {
441
+ return [{ path: "unknown", message: response }];
442
+ }
443
+ if (typeof response === "object" && response !== null) {
444
+ const responseObj = response;
445
+ if (responseObj.message && Array.isArray(responseObj.message)) {
446
+ return responseObj.message.map((msg) => ({
447
+ path: "unknown",
448
+ message: msg
449
+ }));
450
+ }
451
+ if (responseObj.message && typeof responseObj.message === "string") {
452
+ return [{ path: "unknown", message: responseObj.message }];
453
+ }
454
+ if (responseObj.error && typeof responseObj.error === "string") {
455
+ return [{ path: "unknown", message: responseObj.error }];
456
+ }
457
+ }
458
+ return [{ path: "unknown", message: "An error occurred" }];
459
+ }
460
+ message(exception) {
461
+ const httpException = exception;
462
+ const response = httpException.getResponse();
463
+ if (typeof response === "string") {
464
+ return response;
465
+ }
466
+ if (typeof response === "object" && response !== null) {
467
+ const responseObj = response;
468
+ if (responseObj.message && typeof responseObj.message === "string") {
469
+ return responseObj.message;
470
+ }
471
+ if (responseObj.error && typeof responseObj.error === "string") {
472
+ return responseObj.error;
473
+ }
474
+ }
475
+ return "An error occurred";
476
+ }
477
+ };
478
+
479
+ // src/module/exception-handler.module.ts
480
+ var ExceptionHandlerModule = class {
481
+ static forRoot(config) {
482
+ const providers = [
483
+ ExceptionHandlerService,
484
+ {
485
+ provide: GlobalExceptionFilter2,
486
+ useFactory: (service) => {
487
+ return new GlobalExceptionFilter2(service, config);
488
+ },
489
+ inject: [ExceptionHandlerService]
490
+ }
491
+ ];
492
+ return {
493
+ module: ExceptionHandlerModule,
494
+ providers,
495
+ exports: [ExceptionHandlerService, GlobalExceptionFilter2],
496
+ global: true
497
+ };
498
+ }
499
+ static forFeature(config) {
500
+ return this.forRoot(config);
501
+ }
502
+ };
503
+ ExceptionHandlerModule = __decorateClass([
504
+ Module({})
505
+ ], ExceptionHandlerModule);
506
+ function initializeFormatters(service) {
507
+ service.registerFormatter(new PrismaExceptionFormatter());
508
+ service.registerFormatter(new DtoExceptionFormatter());
509
+ service.registerFormatter(new HttpExceptionFormatter());
510
+ service.registerFormatter(new UnknownExceptionFormatter());
511
+ }
512
+ export {
513
+ DtoValidationFormatter,
514
+ ExceptionHandlerModule,
515
+ GlobalExceptionFilter,
516
+ OtherExceptionFormatter,
517
+ PrismaExceptionFormatter,
518
+ initializeFormatters
519
+ };
520
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/formatters/prisma-exception.formatter.ts","../src/formatters/dto-validation.formatter.ts","../src/formatters/other-exception.formatter.ts","../src/exception-filter/global-exception.filter.ts","../src/module/exception-handler.module.ts","../src/services/exception-handler.service.ts","../src/constants/default-messages.ts","../src/formatters/unknown-exception.formatter.ts","../src/filter/global-exception.filter.ts","../src/formatters/dto-exception.formatter.ts","../src/formatters/http-exception.formatter.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport {\n PrismaClientKnownRequestError,\n PrismaClientValidationError,\n PrismaClientRustPanicError,\n PrismaClientInitializationError,\n} from '@prisma/client/runtime/library';\nimport { IErrorMessage } from '../interfaces/error-message.interface';\nimport { ExceptionFormatter } from '../interfaces/exception-formatter.interface';\n\ntype PrismaError =\n | PrismaClientKnownRequestError\n | PrismaClientValidationError\n | PrismaClientRustPanicError\n | PrismaClientInitializationError\n | unknown;\n\n@Injectable()\nexport class PrismaExceptionFormatter implements ExceptionFormatter {\n supports(exception: unknown): boolean {\n return (\n exception instanceof PrismaClientKnownRequestError ||\n exception instanceof PrismaClientValidationError ||\n exception instanceof PrismaClientRustPanicError ||\n exception instanceof PrismaClientInitializationError\n );\n }\n\n format(exception: unknown): IErrorMessage[] {\n return this.formatError(exception as PrismaError);\n }\n\n message(_exception: unknown): string {\n return 'Database error';\n }\n\n formatError(exception: PrismaError): IErrorMessage[] {\n if (exception instanceof PrismaClientKnownRequestError) {\n return this.formatPrismaError(exception);\n }\n\n if (\n exception instanceof PrismaClientValidationError ||\n exception instanceof PrismaClientRustPanicError\n ) {\n return this.formatQueryError(exception);\n }\n\n if (exception instanceof PrismaClientInitializationError) {\n return this.formatInitializationError(exception);\n }\n\n return this.formatUnknownError(exception);\n }\n\n private formatPrismaError(exception: PrismaClientKnownRequestError): IErrorMessage[] {\n const code = exception.code;\n const meta = exception.meta as Record<string, unknown> | undefined;\n\n switch (code) {\n case 'P2002': {\n const target = meta?.target as string[] | undefined;\n const field = target?.[0] || 'field';\n return [\n {\n path: field,\n message: `A record with this ${field} already exists.`,\n },\n ];\n }\n case 'P2003': {\n const fieldName = meta?.field_name as string | undefined;\n return [\n {\n path: fieldName || 'field',\n message: `The referenced ${fieldName || 'record'} does not exist.`,\n },\n ];\n }\n case 'P2005': {\n const fieldName = meta?.field_name as string | undefined;\n return [\n {\n path: fieldName || 'field',\n message: `The value for ${fieldName || 'field'} is invalid.`,\n },\n ];\n }\n case 'P2006': {\n const fieldName = meta?.field_name as string | undefined;\n return [\n {\n path: fieldName || 'field',\n message: `The ${fieldName || 'field'} field is required.`,\n },\n ];\n }\n case 'P2025': {\n return [\n {\n path: 'record',\n message: 'The requested record does not exist.',\n },\n ];\n }\n default:\n return [\n {\n path: 'database',\n message: 'Database operation failed.',\n },\n ];\n }\n }\n\n private formatQueryError(\n exception: PrismaClientValidationError | PrismaClientRustPanicError,\n ): IErrorMessage[] {\n let message = 'Invalid database query.';\n\n if (exception instanceof PrismaClientRustPanicError) {\n message = 'Database engine panic occurred.';\n }\n\n return [\n {\n path: 'database',\n message,\n },\n ];\n }\n\n private formatInitializationError(exception: PrismaClientInitializationError): IErrorMessage[] {\n return [\n {\n path: 'database',\n message: `Database initialization error: ${exception.message}`,\n },\n ];\n }\n\n private formatUnknownError(exception: unknown): IErrorMessage[] {\n return [\n {\n path: 'unknown',\n message:\n exception instanceof Error ? exception.message : 'An unexpected database error occurred.',\n },\n ];\n }\n}\n","import { Injectable } from '@nestjs/common';\nimport { HttpException } from '@nestjs/common';\nimport { IErrorMessage } from '../interfaces/error-message.interface';\n\ninterface ValidationError {\n property: string;\n constraints?: Record<string, string>;\n children?: ValidationError[];\n}\n\n@Injectable()\nexport class DtoValidationFormatter {\n formatDtoValidationException(exception: HttpException): IErrorMessage[] {\n const responseBody: unknown = exception.getResponse();\n\n if (\n typeof responseBody === 'object' &&\n responseBody !== null &&\n 'message' in responseBody &&\n Array.isArray((responseBody as Record<string, unknown>).message)\n ) {\n const messages = (responseBody as Record<string, unknown>).message as unknown[];\n const firstMessage = messages[0];\n\n if (\n firstMessage &&\n typeof firstMessage === 'object' &&\n firstMessage !== null &&\n 'property' in firstMessage\n ) {\n const validationErrors = messages as ValidationError[];\n return validationErrors.map((error: ValidationError) => ({\n path: error.property,\n message: error.constraints\n ? Object.values(error.constraints).join(', ')\n : 'Validation error',\n }));\n }\n }\n\n return [\n {\n path: 'http_error',\n message:\n typeof responseBody === 'object' && responseBody !== null && 'message' in responseBody\n ? String((responseBody as Record<string, unknown>).message)\n : 'An HTTP error occurred',\n },\n ];\n }\n}\n","import { Injectable } from '@nestjs/common';\nimport { IErrorMessage } from '../interfaces/error-message.interface';\n\n@Injectable()\nexport class OtherExceptionFormatter {\n formatOtherError(exception: unknown): IErrorMessage[] {\n if (\n exception &&\n typeof exception === 'object' &&\n 'path' in exception &&\n 'message' in exception\n ) {\n return [\n {\n path: String((exception as Record<string, unknown>).path),\n message: String((exception as Record<string, unknown>).message),\n },\n ];\n }\n\n const message =\n exception && typeof exception === 'object' && 'message' in exception\n ? String((exception as Record<string, unknown>).message)\n : 'An unexpected error occurred';\n\n return [\n {\n path: 'unknown',\n message,\n },\n ];\n }\n}\n","import {\n ExceptionFilter,\n Catch,\n ArgumentsHost,\n HttpException,\n HttpStatus,\n Logger,\n} from '@nestjs/common';\nimport { Request, Response } from 'express';\nimport {\n PrismaClientKnownRequestError,\n PrismaClientValidationError,\n PrismaClientRustPanicError,\n PrismaClientUnknownRequestError,\n PrismaClientInitializationError,\n} from '@prisma/client/runtime/library';\nimport { PrismaExceptionFormatter } from '../formatters/prisma-exception.formatter';\nimport { DtoValidationFormatter } from '../formatters/dto-validation.formatter';\nimport { OtherExceptionFormatter } from '../formatters/other-exception.formatter';\nimport { IErrorMessage } from '../interfaces/error-message.interface';\n\n@Catch()\nexport class GlobalExceptionFilter implements ExceptionFilter {\n constructor(\n private readonly prismaExceptionFormatter: PrismaExceptionFormatter,\n private readonly dtoValidationFormatter: DtoValidationFormatter,\n private readonly otherValidationFormatter: OtherExceptionFormatter,\n ) {}\n\n private readonly logger = new Logger(GlobalExceptionFilter.name);\n\n private getErrorMessage(exception: unknown): string {\n if (\n exception instanceof PrismaClientKnownRequestError ||\n exception instanceof PrismaClientValidationError ||\n exception instanceof PrismaClientRustPanicError ||\n exception instanceof PrismaClientUnknownRequestError ||\n exception instanceof PrismaClientInitializationError\n ) {\n return 'Database error';\n }\n\n if (exception instanceof HttpException) {\n return (exception as HttpException).message || 'HTTP error';\n }\n\n return 'Internal server error';\n }\n\n catch(exception: unknown, host: ArgumentsHost): void {\n const ctx = host.switchToHttp();\n\n const response = ctx.getResponse<Response>();\n const request = ctx.getRequest<Request>();\n\n const status =\n exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;\n\n let errorMessages: IErrorMessage[] = [{ path: 'unknown', message: 'Internal server error' }];\n\n if (\n exception instanceof PrismaClientKnownRequestError ||\n exception instanceof PrismaClientValidationError ||\n exception instanceof PrismaClientRustPanicError ||\n exception instanceof PrismaClientUnknownRequestError ||\n exception instanceof PrismaClientInitializationError\n ) {\n errorMessages = this.prismaExceptionFormatter.formatError(exception);\n } else if (exception instanceof HttpException) {\n errorMessages = this.dtoValidationFormatter.formatDtoValidationException(\n exception as HttpException,\n );\n } else {\n errorMessages = this.otherValidationFormatter.formatOtherError(exception);\n }\n\n this.logger.error(\n `${request.method} ${request.url}`,\n JSON.stringify(errorMessages),\n 'ExceptionFilter',\n );\n\n response.status(status).json({\n success: false,\n message: this.getErrorMessage(exception),\n errorMessages,\n });\n }\n}\n","import { DynamicModule, Module } from '@nestjs/common';\nimport { ExceptionHandlerService } from '../services/exception-handler.service';\nimport { GlobalExceptionFilter } from '../filter/global-exception.filter';\nimport { ExceptionHandlerConfig } from '../interfaces/exception-handler-config.interface';\nimport { PrismaExceptionFormatter } from '../formatters/prisma-exception.formatter';\nimport { DtoExceptionFormatter } from '../formatters/dto-exception.formatter';\nimport { HttpExceptionFormatter } from '../formatters/http-exception.formatter';\nimport { UnknownExceptionFormatter } from '../formatters/unknown-exception.formatter';\n\n@Module({})\nexport class ExceptionHandlerModule {\n static forRoot(config?: ExceptionHandlerConfig): DynamicModule {\n const providers = [\n ExceptionHandlerService,\n {\n provide: GlobalExceptionFilter,\n useFactory: (service: ExceptionHandlerService) => {\n return new GlobalExceptionFilter(service, config);\n },\n inject: [ExceptionHandlerService],\n },\n ];\n\n return {\n module: ExceptionHandlerModule,\n providers,\n exports: [ExceptionHandlerService, GlobalExceptionFilter],\n global: true,\n };\n }\n\n static forFeature(config?: ExceptionHandlerConfig): DynamicModule {\n return this.forRoot(config);\n }\n}\n\n// Initialize formatters\nexport function initializeFormatters(service: ExceptionHandlerService): void {\n service.registerFormatter(new PrismaExceptionFormatter());\n service.registerFormatter(new DtoExceptionFormatter());\n service.registerFormatter(new HttpExceptionFormatter());\n service.registerFormatter(new UnknownExceptionFormatter());\n}\n","import { Injectable } from '@nestjs/common';\nimport { ExceptionFormatter } from '../interfaces/exception-formatter.interface';\nimport { ErrorMessage } from '../interfaces/error-message.interface';\nimport { UnknownExceptionFormatter } from '../formatters/unknown-exception.formatter';\n\n@Injectable()\nexport class ExceptionHandlerService {\n private formatters: ExceptionFormatter[] = [];\n private defaultFormatter: ExceptionFormatter;\n\n constructor() {\n this.defaultFormatter = new UnknownExceptionFormatter();\n }\n\n registerFormatter(formatter: ExceptionFormatter): void {\n this.formatters.push(formatter);\n }\n\n getFormatter(exception: unknown): ExceptionFormatter {\n for (const formatter of this.formatters) {\n if (formatter.supports(exception)) {\n return formatter;\n }\n }\n return this.defaultFormatter;\n }\n\n formatException(exception: unknown): { errors: ErrorMessage[]; message: string } {\n const formatter = this.getFormatter(exception);\n const errors = formatter.format(exception);\n const message = formatter.message(exception);\n\n return { errors, message };\n }\n\n formatErrors(exception: unknown): ErrorMessage[] {\n const formatter = this.getFormatter(exception);\n return formatter.format(exception);\n }\n\n getErrorMessage(exception: unknown): string {\n const formatter = this.getFormatter(exception);\n return formatter.message(exception);\n }\n\n getAllFormatters(): ExceptionFormatter[] {\n return [...this.formatters];\n }\n}\n","export const DEFAULT_ERROR_MESSAGES = {\n UNKNOWN_ERROR: 'An unexpected error occurred',\n VALIDATION_ERROR: 'Validation failed',\n DATABASE_ERROR: 'Database error',\n NOT_FOUND: 'Resource not found',\n UNAUTHORIZED: 'Unauthorized access',\n FORBIDDEN: 'Access forbidden',\n CONFLICT: 'Conflict occurred',\n BAD_REQUEST: 'Bad request',\n};\n\nexport const PRISMA_ERROR_MESSAGES: Record<string, string> = {\n P2002: 'A record with this {field} already exists.',\n P2003: 'This {field} does not exist.',\n P2005: 'Invalid value for {field}.',\n P2006: 'Invalid format for {field}.',\n P2025: 'Record not found.',\n};\n\nexport const DEFAULT_PATH = 'unknown';\n","import { ExceptionFormatter } from '../interfaces/exception-formatter.interface';\nimport { ErrorMessage } from '../interfaces/error-message.interface';\nimport { DEFAULT_PATH } from '../constants/default-messages';\n\nexport class UnknownExceptionFormatter implements ExceptionFormatter {\n supports(_exception: unknown): boolean {\n return true;\n }\n\n format(_exception: unknown): ErrorMessage[] {\n return [\n {\n path: DEFAULT_PATH,\n message: 'Internal server error',\n },\n ];\n }\n\n message(_exception: unknown): string {\n return 'Internal server error';\n }\n}\n","import {\n ExceptionFilter,\n Catch,\n ArgumentsHost,\n HttpException,\n HttpStatus,\n Logger,\n} from '@nestjs/common';\nimport { Request, Response } from 'express';\nimport { ExceptionHandlerService } from '../services/exception-handler.service';\nimport { StandardErrorResponse } from '../interfaces/error-message.interface';\nimport { ExceptionHandlerConfig } from '../interfaces/exception-handler-config.interface';\n\n@Catch()\nexport class GlobalExceptionFilter implements ExceptionFilter {\n private readonly logger = new Logger(GlobalExceptionFilter.name);\n private config: ExceptionHandlerConfig;\n\n constructor(\n private exceptionHandlerService: ExceptionHandlerService,\n config?: ExceptionHandlerConfig,\n ) {\n this.config = config || { enableLogging: true, hideStackTrace: false };\n }\n\n catch(exception: unknown, host: ArgumentsHost): void {\n const ctx = host.switchToHttp();\n const response = ctx.getResponse<Response>();\n const request = ctx.getRequest<Request>();\n\n const { errors, message } = this.exceptionHandlerService.formatException(exception);\n const status = this.getStatusCode(exception);\n\n const errorResponse: StandardErrorResponse = {\n success: false,\n message,\n errorMessages: errors,\n };\n\n if (this.config.enableLogging) {\n this.logError(request, status, errors, exception);\n }\n\n response.status(status).json(errorResponse);\n }\n\n private getStatusCode(exception: unknown): number {\n if (exception instanceof HttpException) {\n return exception.getStatus();\n }\n return HttpStatus.INTERNAL_SERVER_ERROR;\n }\n\n private logError(\n request: Request,\n status: number,\n errorMessages: { path: string; message: string }[],\n exception: unknown,\n ): void {\n const method = request.method;\n const url = request.url;\n const timestamp = new Date().toISOString();\n\n const logData = {\n timestamp,\n method,\n url,\n status,\n errorMessages,\n stack: this.config.hideStackTrace ? undefined : (exception as Error)?.stack,\n };\n\n this.logger.error(`${method} ${url} - ${status}`, JSON.stringify(logData));\n }\n}\n","import { ValidationError } from '@nestjs/common';\nimport { ExceptionFormatter } from '../interfaces/exception-formatter.interface';\nimport { ErrorMessage } from '../interfaces/error-message.interface';\n\nexport class DtoExceptionFormatter implements ExceptionFormatter {\n supports(exception: unknown): boolean {\n if (!exception || typeof exception !== 'object') {\n return false;\n }\n\n const error = exception as Record<string, unknown>;\n return (\n Array.isArray(error.validationErrors) ||\n (Array.isArray(error.children) && error.constraints !== undefined)\n );\n }\n\n format(exception: unknown): ErrorMessage[] {\n const error = exception as Record<string, unknown>;\n const validationErrors = error.validationErrors as ValidationError[] | undefined;\n const children = error.children as ValidationError[] | undefined;\n\n if (validationErrors) {\n return this.formatValidationErrors(validationErrors);\n }\n\n if (children) {\n return this.formatChildrenErrors(children);\n }\n\n return [{ path: 'unknown', message: 'Validation failed' }];\n }\n\n message(exception: unknown): string {\n const error = exception as Record<string, unknown>;\n const validationErrors = error.validationErrors as ValidationError[] | undefined;\n const children = error.children as ValidationError[] | undefined;\n\n if (validationErrors && validationErrors.length > 0) {\n const firstError = validationErrors[0];\n const constraints = firstError.constraints;\n if (constraints) {\n return Object.values(constraints)[0];\n }\n }\n\n if (children && children.length > 0) {\n return 'Validation failed for nested fields';\n }\n\n return 'Validation failed';\n }\n\n private formatValidationErrors(errors: ValidationError[]): ErrorMessage[] {\n return errors.flatMap((error) => {\n const constraints = error.constraints;\n if (constraints) {\n return Object.entries(constraints).map(([, value]) => ({\n path: error.property,\n message: value,\n }));\n }\n return [];\n });\n }\n\n private formatChildrenErrors(children: ValidationError[]): ErrorMessage[] {\n return children.flatMap((child) => {\n const constraints = child.constraints;\n if (constraints) {\n return Object.entries(constraints).map(([, value]) => ({\n path: child.property,\n message: value,\n }));\n }\n return [];\n });\n }\n}\n","import { HttpException } from '@nestjs/common';\nimport { ExceptionFormatter } from '../interfaces/exception-formatter.interface';\nimport { ErrorMessage } from '../interfaces/error-message.interface';\n\nexport class HttpExceptionFormatter implements ExceptionFormatter {\n supports(exception: unknown): boolean {\n return exception instanceof HttpException;\n }\n\n format(exception: unknown): ErrorMessage[] {\n const httpException = exception as HttpException;\n const response = httpException.getResponse();\n\n if (typeof response === 'string') {\n return [{ path: 'unknown', message: response }];\n }\n\n if (typeof response === 'object' && response !== null) {\n const responseObj = response as Record<string, unknown>;\n\n if (responseObj.message && Array.isArray(responseObj.message)) {\n // Handle validation errors from class-validator in HTTP exceptions\n return (responseObj.message as string[]).map((msg) => ({\n path: 'unknown',\n message: msg,\n }));\n }\n\n if (responseObj.message && typeof responseObj.message === 'string') {\n return [{ path: 'unknown', message: responseObj.message }];\n }\n\n if (responseObj.error && typeof responseObj.error === 'string') {\n return [{ path: 'unknown', message: responseObj.error }];\n }\n }\n\n return [{ path: 'unknown', message: 'An error occurred' }];\n }\n\n message(exception: unknown): string {\n const httpException = exception as HttpException;\n const response = httpException.getResponse();\n\n if (typeof response === 'string') {\n return response;\n }\n\n if (typeof response === 'object' && response !== null) {\n const responseObj = response as Record<string, unknown>;\n\n if (responseObj.message && typeof responseObj.message === 'string') {\n return responseObj.message;\n }\n\n if (responseObj.error && typeof responseObj.error === 'string') {\n return responseObj.error;\n }\n }\n\n return 'An error occurred';\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYA,IAAM,2BAAN,MAA6D;AAAA,EAClE,SAAS,WAA6B;AACpC,WACE,qBAAqB,iCACrB,qBAAqB,+BACrB,qBAAqB,8BACrB,qBAAqB;AAAA,EAEzB;AAAA,EAEA,OAAO,WAAqC;AAC1C,WAAO,KA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AC,YAAqC;AAChD,iBAAO,IAAIA,uBAAsB,SAAS,MAAM;AAAA,QAClD;AAAA,QACA,QAAQ,CAAC,uBAAuB;AAAA,MAClC;AAAA,IACF;AAEA,WAAO;AAAA,MACL,QAAQ;AAAA,MACR;AAAA,MACA,SAAS,CAAC,yBAAyBA,sBAAqB;AAAA,MACxD,QAAQ;AAAA,IACV;AAAA,EACF;AAAA,EAEA,OAAO,WAAW,QAAgD;AAChE,WAAO,KAAK,QAAQ,MAAM;AAAA,EAC5B;AACF;AAxBa,yBAAN;AAAA,EADN,OAAO,CAAC,CAAC;AAAA,GACG;AA2BN,SAAS,qBAAqB,SAAwC;AAC3E,UAAQ,kBAAkB,IAAI,yBAAyB,CAAC;AACxD,UAAQ,kBAAkB,IAAI,sBAAsB,CAAC;AACrD,UAAQ,kBAAkB,IAAI,uBAAuB,CAAC;AACtD,UAAQ,kBAAkB,IAAI,0BAA0B,CAAC;AAC3D;","names":["Injectable","Injectable","Injectable","Injectable","PrismaClientKnownRequestError","PrismaClientValidationError","PrismaClientRustPanicError","PrismaClientInitializationError","PrismaClientKnownRequestError","PrismaClientValidationError","PrismaClientRustPanicError","PrismaClientInitializationError","Injectable","Injectable","Catch","HttpException","HttpStatus","Logger","GlobalExceptionFilter","Logger","HttpException","HttpStatus","Catch","HttpException","GlobalExceptionFilter"]}