-
Notifications
You must be signed in to change notification settings - Fork 5
/
errors.d.ts
64 lines (55 loc) · 1.57 KB
/
errors.d.ts
1
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
export interface IErrorInfo {
isSystem: boolean;
type: string;
error?: any;
}
export interface IDispatchErrorInfo extends IErrorInfo {
isSystem: true;
type: 'DispatchError';
/** Message returned with response */
message: any;
/** Response code */
code: number;
/** Error name */
name?: string;
}
export interface IDatabaseConnectionErrorInfo extends IErrorInfo {
isSystem: true;
type: 'DatabaseConnectionError';
/** Connection name */
name: string;
}
export interface ISessionErrorInfo extends IErrorInfo {
isSystem: true;
type: 'SessionError';
code: 500;
message: string;
}
export interface ISocketUnhandledErrorInfo extends IErrorInfo {
isSystem: true;
type: 'SocketUnhandledError';
/** Disconnection code */
code: number;
/** Driver message */
message: string;
}
export interface IRequestErrorInfo extends IErrorInfo {
isSystem: true;
type: 'RequestError';
code: 400;
url: string;
/** Error message */
message: any;
/** Raw request body */
body?: Buffer;
}
type KnownErrors = IDispatchErrorInfo | IDatabaseConnectionErrorInfo | ISessionErrorInfo | ISocketUnhandledErrorInfo | IRequestErrorInfo | IErrorInfo;
export function onError (handler: (info: KnownErrors) => void): void;
export function emitError (info: KnownErrors): void;
export function clearErrorStack (stack: string): string;
export function splitError (error: any): string[];
export class HttpError {
public message: any;
public code: number;
constructor (message: any, code?: number);
}