1 | import { StringValueMap } from '../data/StringValueMap';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | export declare class ApplicationException extends Error {
|
41 |
|
42 | message: string;
|
43 |
|
44 | category: string;
|
45 |
|
46 | status: number;
|
47 |
|
48 | code: string;
|
49 |
|
50 | details: StringValueMap;
|
51 |
|
52 | correlation_id: string;
|
53 |
|
54 | stack_trace: string;
|
55 |
|
56 | cause: string;
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | constructor(category?: string, correlation_id?: string, code?: string, message?: string);
|
66 | /**
|
67 | * Gets original error wrapped by this exception as a string message.
|
68 | *
|
69 | * @returns an original error message.
|
70 | */
|
71 | getCauseString(): string;
|
72 | /**
|
73 | * Sets original error wrapped by this exception as a string message.
|
74 | *
|
75 | * @param value an original error message.
|
76 | */
|
77 | setCauseString(value: string): void;
|
78 | /**
|
79 | * Gets a stack trace where this exception occured.
|
80 | *
|
81 | * @returns a stack trace as a string.
|
82 | */
|
83 | getStackTraceString(): string;
|
84 | /**
|
85 | * Sets a stack trace where this exception occured.
|
86 | *
|
87 | * @param value a stack trace as a string
|
88 | */
|
89 | setStackTraceString(value: string): void;
|
90 | /**
|
91 | * Sets a unique error code.
|
92 | *
|
93 | * This method returns reference to this exception to implement Builder pattern
|
94 | * to chain additional calls.
|
95 | *
|
96 | * @param code a unique error code
|
97 | * @returns this exception object
|
98 | */
|
99 | withCode(code: string): ApplicationException;
|
100 | /**
|
101 | * Sets a original error wrapped by this exception
|
102 | *
|
103 | * This method returns reference to this exception to implement Builder pattern
|
104 | * to chain additional calls.
|
105 | *
|
106 | * @param cause original error object
|
107 | * @returns this exception object
|
108 | */
|
109 | withCause(cause: Error): ApplicationException;
|
110 | /**
|
111 | * Sets a HTTP status code which shall be returned by REST calls.
|
112 | *
|
113 | * This method returns reference to this exception to implement Builder pattern
|
114 | * to chain additional calls.
|
115 | *
|
116 | * @param status an HTTP error code.
|
117 | * @returns this exception object
|
118 | */
|
119 | withStatus(status: number): ApplicationException;
|
120 | /**
|
121 | * Sets a parameter for additional error details.
|
122 | * This details can be used to restore error description in other languages.
|
123 | *
|
124 | * This method returns reference to this exception to implement Builder pattern
|
125 | * to chain additional calls.
|
126 | *
|
127 | * @param key a details parameter name
|
128 | * @param value a details parameter name
|
129 | * @returns this exception object
|
130 | */
|
131 | withDetails(key: string, value: any): ApplicationException;
|
132 | /**
|
133 | * Sets a correlation id which can be used to trace this error through a call chain.
|
134 | *
|
135 | * This method returns reference to this exception to implement Builder pattern
|
136 | * to chain additional calls.
|
137 | *
|
138 | * @param correlationId a unique transaction id to trace error through call chain
|
139 | * @returns this exception object
|
140 | */
|
141 | withCorrelationId(correlationId: string): ApplicationException;
|
142 | /**
|
143 | * Sets a stack trace for this error.
|
144 | *
|
145 | * This method returns reference to this exception to implement Builder pattern
|
146 | * to chain additional calls.
|
147 | *
|
148 | * @param stackTrace a stack trace where this error occured
|
149 | * @returns this exception object
|
150 | */
|
151 | withStackTrace(stackTrace: string): ApplicationException;
|
152 | /**
|
153 | * Wraps another exception into an application exception object.
|
154 | *
|
155 | * If original exception is of ApplicationException type it is returned without changes.
|
156 | * Otherwise a new ApplicationException is created and original error is set as its cause.
|
157 | *
|
158 | * @param cause an original error object
|
159 | * @returns an original or newly created ApplicationException
|
160 | */
|
161 | wrap(cause: any): ApplicationException;
|
162 | /**
|
163 | * Wraps another exception into specified application exception object.
|
164 | *
|
165 | * If original exception is of ApplicationException type it is returned without changes.
|
166 | * Otherwise the original error is set as a cause to specified ApplicationException object.
|
167 | *
|
168 | * @param error an ApplicationException object to wrap the cause
|
169 | * @param cause an original error object
|
170 | * @returns an original or newly created ApplicationException
|
171 | *
|
172 | * @see [[wrap]]
|
173 | */
|
174 | static wrapError(error: ApplicationException, cause: any): ApplicationException;
|
175 | /**
|
176 | * Unwraps original exception through wrapped exception objects.
|
177 | *
|
178 | * Many frameworks like Seneca or restify wrap original exception.
|
179 | * That may result in propagating less specific errors and can hide
|
180 | * causes of the errors.
|
181 | *
|
182 | * @param error an error object
|
183 | * @returns an original error object
|
184 | */
|
185 | static unwrapError(error: any): any;
|
186 | }
|