nestjs-exception-handler 4.2.0 → 4.3.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.d.ts CHANGED
@@ -1,15 +1,14 @@
1
- import { PrismaClientKnownRequestError, PrismaClientValidationError, PrismaClientRustPanicError, PrismaClientInitializationError } from '@prisma/client/runtime/library';
2
1
  import { HttpException, ExceptionFilter, ArgumentsHost, DynamicModule } from '@nestjs/common';
2
+ import { PrismaClientKnownRequestError, PrismaClientValidationError, PrismaClientRustPanicError, PrismaClientInitializationError } from '@prisma/client/runtime/library';
3
3
 
4
- interface IErrorMessage {
4
+ interface ErrorMessage {
5
5
  path: string;
6
- message: string;
6
+ message: string[];
7
7
  }
8
- type ErrorMessage = IErrorMessage;
9
- interface StandardErrorResponse {
8
+ interface ErrorResponse {
10
9
  success: boolean;
11
10
  message: string;
12
- errorMessages: IErrorMessage[];
11
+ errorMessages: ErrorMessage[];
13
12
  }
14
13
 
15
14
  interface ExceptionFormatter {
@@ -23,12 +22,17 @@ interface ExceptionHandlerConfig {
23
22
  hideStackTrace?: boolean;
24
23
  }
25
24
 
25
+ declare class ValidationErrorFormatter {
26
+ formatValidationErrors(exception: HttpException): ErrorMessage[];
27
+ private formatNestedValidationErrors;
28
+ }
29
+
26
30
  type PrismaError = PrismaClientKnownRequestError | PrismaClientValidationError | PrismaClientRustPanicError | PrismaClientInitializationError | unknown;
27
31
  declare class PrismaExceptionFormatter implements ExceptionFormatter {
28
32
  supports(exception: unknown): boolean;
29
- format(exception: unknown): IErrorMessage[];
33
+ format(exception: unknown): ErrorMessage[];
30
34
  message(_exception: unknown): string;
31
- formatError(exception: PrismaError): IErrorMessage[];
35
+ formatError(exception: PrismaError): ErrorMessage[];
32
36
  private formatPrismaError;
33
37
  private formatQueryError;
34
38
  private formatInitializationError;
@@ -36,27 +40,14 @@ declare class PrismaExceptionFormatter implements ExceptionFormatter {
36
40
  }
37
41
 
38
42
  declare class DtoValidationFormatter {
39
- formatDtoValidationException(exception: HttpException): IErrorMessage[];
40
- }
41
-
42
- declare class OtherExceptionFormatter {
43
- formatOtherError(exception: unknown): IErrorMessage[];
44
- }
45
-
46
- declare class GlobalExceptionFilter implements ExceptionFilter {
47
- private readonly prismaExceptionFormatter;
48
- private readonly dtoValidationFormatter;
49
- private readonly otherValidationFormatter;
50
- constructor(prismaExceptionFormatter: PrismaExceptionFormatter, dtoValidationFormatter: DtoValidationFormatter, otherValidationFormatter: OtherExceptionFormatter);
51
- private readonly logger;
52
- private getErrorMessage;
53
- catch(exception: unknown, host: ArgumentsHost): void;
43
+ formatDtoValidationException(exception: HttpException): ErrorMessage[];
54
44
  }
55
45
 
56
46
  declare class ExceptionHandlerService {
57
47
  private formatters;
58
48
  private defaultFormatter;
59
49
  constructor();
50
+ private registerFormatters;
60
51
  registerFormatter(formatter: ExceptionFormatter): void;
61
52
  getFormatter(exception: unknown): ExceptionFormatter;
62
53
  formatException(exception: unknown): {
@@ -68,10 +59,25 @@ declare class ExceptionHandlerService {
68
59
  getAllFormatters(): ExceptionFormatter[];
69
60
  }
70
61
 
62
+ declare class GlobalExceptionFilter implements ExceptionFilter {
63
+ private exceptionHandlerService;
64
+ private readonly logger;
65
+ private config;
66
+ constructor(exceptionHandlerService: ExceptionHandlerService, config?: ExceptionHandlerConfig);
67
+ catch(exception: unknown, host: ArgumentsHost): void;
68
+ private getStatusCode;
69
+ private logError;
70
+ }
71
+
71
72
  declare class ExceptionHandlerModule {
72
73
  static forRoot(config?: ExceptionHandlerConfig): DynamicModule;
73
74
  static forFeature(config?: ExceptionHandlerConfig): DynamicModule;
74
75
  }
75
76
  declare function initializeFormatters(service: ExceptionHandlerService): void;
76
77
 
77
- export { DtoValidationFormatter, ErrorMessage, ExceptionFormatter, ExceptionHandlerConfig, ExceptionHandlerModule, GlobalExceptionFilter, IErrorMessage, OtherExceptionFormatter, PrismaExceptionFormatter, StandardErrorResponse, initializeFormatters };
78
+ declare class HttpErrorFormatter {
79
+ formatHttpException(exception: HttpException): ErrorMessage[];
80
+ getMessage(exception: HttpException): string;
81
+ }
82
+
83
+ export { DtoValidationFormatter, ErrorMessage, ErrorResponse, ExceptionFormatter, ExceptionHandlerConfig, ExceptionHandlerModule, ExceptionHandlerService, GlobalExceptionFilter, HttpErrorFormatter, PrismaExceptionFormatter, ValidationErrorFormatter, initializeFormatters };