-
Notifications
You must be signed in to change notification settings - Fork 35
/
UALError.ts
48 lines (43 loc) · 1.29 KB
/
UALError.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
/**
* Types of errors that the UALError class can represent
*/
export enum UALErrorType {
UAL = 'UAL', // Generic error
Login = 'Login',
Logout = 'Logout',
Signing = 'Signing',
Validation = 'Validation',
Initialization = 'Initialization', // Covers situations like Scatter.connect, module not loading, etc.
DataRequest = 'DataRequest', // Errors fetching data like accountName, keys, etc.
Unsupported = 'Unsupported', // Thrown from an unsupported operation
}
/**
* Base error class for UAL errors.
*/
export class UALError extends Error {
/**
* The type of the error
*/
public readonly type: UALErrorType
/**
* The underlying Error (if any) that caused the current error.
*/
public readonly cause: Error | null
/**
* The name of the authenticator that is the source of the error.
*/
public readonly source: string
/**
* @param message Message describing the error
*
* @param source The name of the authenticator that is the source of the error
*
* @param cause The underlying Error (if any) that resulted in the current one being thrown
*/
constructor(message: string, type: UALErrorType, cause: Error | null, source: string) {
super(message)
this.type = type
this.cause = cause
this.source = source
}
}