-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy patherrors.ts
More file actions
71 lines (60 loc) · 2.17 KB
/
errors.ts
File metadata and controls
71 lines (60 loc) · 2.17 KB
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
/**
* @prettier
*/
// Descriptive error types for common issues which may arise
// during the operation of BitGoJS or BitGoExpress
// Each subclass needs the explicit Object.setPrototypeOf() so that instanceof will work correctly.
// See https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
import { BitGoJsError } from '@bitgo/sdk-core';
export class TlsConfigurationError extends BitGoJsError {
public constructor(message?: string) {
super(message || 'TLS is configuration is invalid');
Object.setPrototypeOf(this, TlsConfigurationError.prototype);
}
}
export class NodeEnvironmentError extends BitGoJsError {
public constructor(message?: string) {
super(message || 'NODE_ENV is invalid for the current bitgo environment');
Object.setPrototypeOf(this, NodeEnvironmentError.prototype);
}
}
export class ApiResponseError extends BitGoJsError {
public readonly status: number;
public readonly result: unknown;
public constructor(message: string | undefined, status: number, result?: unknown) {
super(message);
Object.setPrototypeOf(this, ApiResponseError.prototype);
this.status = status;
this.result = result;
}
}
export class IpcError extends BitGoJsError {
public constructor(message: string) {
super(message);
Object.setPrototypeOf(this, IpcError.prototype);
}
}
export class ExternalSignerConfigError extends BitGoJsError {
public constructor(message?: string) {
super(message || 'External signer configuration is invalid');
}
}
export class LightningSignerConfigError extends BitGoJsError {
public constructor(message?: string) {
super(message || 'Lightning signer configuration is invalid');
}
}
export class BitGoExpressError extends BitGoJsError {
public constructor(message?: string) {
super(message);
Object.setPrototypeOf(this, BitGoExpressError.prototype);
}
}
export class ValidationError extends BitGoJsError {
public readonly status = 400;
public override readonly name = 'ValidationError';
public constructor(message: string) {
super(message);
Object.setPrototypeOf(this, ValidationError.prototype);
}
}