1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export class AppError extends Error {
|
10 | |
11 |
|
12 |
|
13 |
|
14 | static instanceOf(value: any): value is AppError;
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 | static notFound(info?: Record<string, any> | undefined, error?: Error | undefined): AppError;
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 | static notImplemented(info?: Record<string, any> | undefined, error?: Error | undefined): AppError;
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 | static serverError(info?: Record<string, any> | undefined, error?: Error | undefined): AppError;
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | static validationError(key: string, info?: Record<string, any> | undefined, error?: Error | undefined): AppError;
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | static format(e?: AppError | Error | undefined | null | {} | string | number | boolean | Function | unknown): Record<string, any>;
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | constructor(key: string, status: number, info?: Record<string, any> | undefined, cause?: Error | undefined);
|
55 | key: string;
|
56 | status: number;
|
57 | info: Record<string, any>;
|
58 | cause: Error | undefined;
|
59 | /**
|
60 | * Use AppError#format when AppError is passed to JSON.stringify().
|
61 | * This is used in the compas insight logger in production mode.
|
62 | */
|
63 | toJSON(): Record<string, any>;
|
64 | /**
|
65 | * Use AppError#format when AppError is passed to console.log / console.error.
|
66 | * This works because it uses `util.inspect` under the hood.
|
67 | * Util#inspect checks if the Symbol `util.inspect.custom` is available.
|
68 | */
|
69 | [inspect.custom](): Record<string, any>;
|
70 | }
|
71 | import { inspect } from "node:util";
|