-
Notifications
You must be signed in to change notification settings - Fork 354
/
errors.ts
46 lines (41 loc) · 1.43 KB
/
errors.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
export class GenericError extends Error {
constructor(public error: string, public error_description: string) {
super(error_description);
Object.setPrototypeOf(this, GenericError.prototype);
}
static fromPayload({
error,
error_description
}: {
error: string;
error_description: string;
}) {
return new GenericError(error, error_description);
}
}
export class AuthenticationError extends GenericError {
constructor(
error: string,
error_description: string,
public state: string,
public appState: any = null
) {
super(error, error_description);
//https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, AuthenticationError.prototype);
}
}
export class TimeoutError extends GenericError {
constructor() {
super('timeout', 'Timeout');
//https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, TimeoutError.prototype);
}
}
export class PopupTimeoutError extends TimeoutError {
constructor(public popup: Window) {
super();
//https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, PopupTimeoutError.prototype);
}
}