1 |
|
2 |
|
3 | import { BitGoJsError } from '@bitgo/sdk-core';
|
4 |
|
5 |
|
6 | export { BitGoJsError };
|
7 |
|
8 | export class TlsConfigurationError extends BitGoJsError {
|
9 | public constructor(message?: string) {
|
10 | super(message || 'TLS is configuration is invalid');
|
11 | }
|
12 | }
|
13 |
|
14 | export class NodeEnvironmentError extends BitGoJsError {
|
15 | public constructor(message?: string) {
|
16 | super(message || 'NODE_ENV is invalid for the current bitgo environment');
|
17 | }
|
18 | }
|
19 |
|
20 | export class UnsupportedCoinError extends BitGoJsError {
|
21 | public constructor(coin: string) {
|
22 | super(`Coin or token type ${coin} not supported or not compiled. Please be sure that you are using the latest version of BitGoJS.`);
|
23 | }
|
24 | }
|
25 |
|
26 | export class AddressTypeChainMismatchError extends BitGoJsError {
|
27 | constructor(addressType: string, chain: number | string) {
|
28 | super(`address type ${addressType} does not correspond to chain ${chain}`);
|
29 | }
|
30 | }
|
31 |
|
32 | export class P2shP2wshUnsupportedError extends BitGoJsError {
|
33 | constructor(message?: string) {
|
34 | super(message || 'p2shP2wsh not supported by this coin');
|
35 | }
|
36 | }
|
37 |
|
38 | export class P2wshUnsupportedError extends BitGoJsError {
|
39 | public constructor(message?: string) {
|
40 | super(message || 'p2wsh not supported by this coin');
|
41 | }
|
42 | }
|
43 |
|
44 | export class P2trUnsupportedError extends BitGoJsError {
|
45 | public constructor(message?: string) {
|
46 | super(message || 'p2tr not supported by this coin');
|
47 | }
|
48 | }
|
49 |
|
50 | export class UnsupportedAddressTypeError extends BitGoJsError {
|
51 | public constructor(message?: string) {
|
52 | super(message || 'invalid address type');
|
53 | }
|
54 | }
|
55 |
|
56 | export class InvalidAddressError extends BitGoJsError {
|
57 | public constructor(message?: string) {
|
58 | super(message || 'invalid address');
|
59 | }
|
60 | }
|
61 |
|
62 | export class InvalidAddressVerificationObjectPropertyError extends BitGoJsError {
|
63 | public constructor(message?: string) {
|
64 | super(message || 'address validation failure');
|
65 | }
|
66 | }
|
67 |
|
68 | export class UnexpectedAddressError extends BitGoJsError {
|
69 | public constructor(message?: string) {
|
70 | super(message || 'address validation failure');
|
71 | }
|
72 | }
|
73 |
|
74 | export class InvalidAddressDerivationPropertyError extends BitGoJsError {
|
75 | public constructor(message?: string) {
|
76 | super(message || 'address chain and/or index are invalid');
|
77 | }
|
78 | }
|
79 |
|
80 | export class WalletRecoveryUnsupported extends BitGoJsError {
|
81 | public constructor(message?: string) {
|
82 | super(message || 'wallet recovery is not supported by this coin');
|
83 | }
|
84 | }
|
85 |
|
86 | export class MethodNotImplementedError extends BitGoJsError {
|
87 | public constructor(message?: string) {
|
88 | super(message || 'method not implemented');
|
89 | }
|
90 | }
|
91 |
|
92 | export class BlockExplorerUnavailable extends BitGoJsError {
|
93 | public constructor(message?: string) {
|
94 | super(message || 'third-party blockexplorer not responding');
|
95 | }
|
96 | }
|
97 |
|
98 | export class InvalidMemoIdError extends InvalidAddressError {
|
99 | public constructor(message?: string) {
|
100 | super(message || 'invalid memo id');
|
101 | }
|
102 | }
|
103 |
|
104 | export class InvalidPaymentIdError extends InvalidAddressError {
|
105 | public constructor(message?: string) {
|
106 | super(message || 'invalid payment id');
|
107 | }
|
108 | }
|
109 |
|
110 | export class KeyRecoveryServiceError extends BitGoJsError {
|
111 | public constructor(message?: string) {
|
112 | super(message || 'key recovery service encountered an error');
|
113 | }
|
114 | }
|
115 |
|
116 | export class AddressGenerationError extends BitGoJsError {
|
117 | public constructor(message?: string) {
|
118 | super(message || 'address generation failed');
|
119 | }
|
120 | }
|
121 |
|
122 | export class EthereumLibraryUnavailableError extends BitGoJsError {
|
123 | public constructor(packageName: string) {
|
124 | super(`Ethereum library required for operation is not available. Please install "${(packageName)}".`);
|
125 | }
|
126 | }
|
127 |
|
128 | export class StellarFederationUserNotFoundError extends BitGoJsError {
|
129 | public constructor(message?: string) {
|
130 | super(message || 'account not found');
|
131 | }
|
132 | }
|
133 |
|
134 | export class ErrorNoInputToRecover extends BitGoJsError {
|
135 | public constructor(message?: string) {
|
136 | super(message || 'No input to recover - aborting!');
|
137 | }
|
138 | }
|
139 |
|
140 | export class InvalidKeyPathError extends BitGoJsError {
|
141 | public constructor(keyPath: string) {
|
142 | super(`invalid keypath: ${keyPath}`);
|
143 | }
|
144 | }
|
145 |
|
146 | export class InvalidTransactionError extends BitGoJsError {
|
147 | public constructor(message?: string) {
|
148 | super(message || 'Invalid transaction');
|
149 | }
|
150 | }
|
151 |
|
152 | export class ApiResponseError<ResponseBodyType = any> extends BitGoJsError {
|
153 | message: string;
|
154 | status: number;
|
155 | result?: ResponseBodyType;
|
156 | invalidToken?: boolean;
|
157 | needsOTP?: boolean;
|
158 |
|
159 | public constructor(message: string, status: number, result?: ResponseBodyType, invalidToken?: boolean, needsOTP?: boolean) {
|
160 | super(message);
|
161 | this.message = message;
|
162 | this.status = status;
|
163 | this.result = result;
|
164 | this.invalidToken = invalidToken;
|
165 | this.needsOTP = needsOTP;
|
166 | }
|
167 | }
|