-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathErrors.ts
89 lines (77 loc) · 2.33 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
export default class YouTubeCastReceiverError extends Error {
cause?: any;
info?: Record<string, any>;
constructor(message: string, cause?: any, info?: Record<string, any>) {
super(message);
this.name = 'YouTubeCastReceiverError';
if (cause) {
this.cause = cause;
}
if (info) {
this.info = info;
}
}
getCauses(): Array<any> {
const causes = [];
let c = this.cause;
while (c) {
causes.push(c);
c = c instanceof YouTubeCastReceiverError ? c.cause : null;
}
return causes;
}
}
export class ConnectionError extends YouTubeCastReceiverError {
constructor(message: string, url: string, cause?: any) {
super(message, cause, { url });
this.name = 'ConnectionError';
}
}
export class AbortError extends YouTubeCastReceiverError {
constructor(message: string, url: string) {
super(message, undefined, { url });
this.name = 'AbortError';
}
}
export class BadResponseError extends YouTubeCastReceiverError {
constructor(message: string, url: string, response: {status: number, statusText: string}) {
super(message, undefined, {url, response});
this.name = 'BadResponseError';
}
}
export class DataError extends YouTubeCastReceiverError {
constructor(message: string, cause?: any, data?: any) {
super(message, cause, { data });
this.name = 'DataError';
}
}
export class IncompleteAPIDataError extends YouTubeCastReceiverError {
constructor(message: string, missing?: string[]) {
super(message, undefined, { missing });
this.name = 'IncompleteAPIDataError';
}
}
export class SessionError extends YouTubeCastReceiverError {
constructor(message: string, cause?: any) {
super(message, cause);
this.name = 'SessionError';
}
}
export class AppError extends YouTubeCastReceiverError {
constructor(message: string, cause?: any) {
super(message, cause);
this.name = 'AppError';
}
}
export class DialServerError extends YouTubeCastReceiverError {
constructor(message: string, cause?: any) {
super(message, cause);
this.name = 'DialServerError';
}
}
export class SenderConnectionError extends YouTubeCastReceiverError {
constructor(message: string, cause?: any, action?: 'connect' | 'disconnect' | 'unknown') {
super(message, cause, { action: action || 'unknown' });
this.name = 'SenderConnectionError';
}
}