generated from jasonsturges/typescript-npm-package
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherrors.ts
108 lines (93 loc) · 2.99 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { TransactionInput } from '@bsv/sdk';
import { Logger } from './logger';
import { ClientOptions, AdminClientOptions, TxInput } from './types';
export class SpvWalletError extends Error {
constructor(message: string) {
super(message);
this.name = this.constructor.name;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
}
export class ErrorInvalidClientOptions extends SpvWalletError {
constructor(logger: Logger, options: ClientOptions) {
super('Invalid options. None of xPub, xPriv nor accessKey is set');
logger.debug('Invalid options: ', options);
}
}
export class ErrorInvalidAdminClientOptions extends SpvWalletError {
constructor(logger: Logger, options: AdminClientOptions) {
super('Invalid options. No adminKey set');
logger.debug('Invalid options: ', options);
}
}
export class ErrorNoXPrivToSignTransaction extends SpvWalletError {
constructor() {
super('Cannot sign transaction without an xPriv');
}
}
export class ErrorClientInitNoXpriv extends SpvWalletError {
constructor() {
super('Init client with xPriv first');
}
}
export class ErrorTxIdsDontMatchToDraft extends SpvWalletError {
input: TxInput;
draftInput: TransactionInput;
constructor(logger: Logger, input: TxInput, index: number, draftInput: TransactionInput) {
super('Input tx ids do not match in draft and transaction hex');
logger.debug('The input: ', input, 'Tx index: ', index, 'The draft', draftInput);
this.input = input;
this.draftInput = draftInput;
}
}
export class ErrorNoAdminKey extends SpvWalletError {
constructor() {
super('Admin key has not been set. Cannot do admin queries.');
}
}
export class ErrorResponse extends SpvWalletError {
response: Response;
content: string;
constructor(logger: Logger, response: Response, content: string) {
super('Received error response');
logger.debug('StatusCode:', response.status, 'Error response:', response, 'The content:', content);
this.response = response;
this.content = content;
}
}
export class ErrorWrongHex extends SpvWalletError {
value: string;
constructor(wrongHex: string) {
super('Provided hexHash is not a valid hex string');
this.value = wrongHex;
}
}
export class ErrorNoXPrivToGenerateTOTP extends SpvWalletError {
constructor() {
super('Cannot generate TOTP without an xPrivKey set');
}
}
export class ErrorNoXPrivToValidateTOTP extends SpvWalletError {
constructor() {
super('Cannot validate TOTP without an xPrivKey set');
}
}
export class ErrorWrongTOTP extends SpvWalletError {
constructor() {
super('TOTP is invalid');
}
}
export class ErrorSyncMerkleRootsTimeout extends SpvWalletError {
constructor() {
super('SyncMerkleRoots operation timed out');
}
}
export class ErrorStaleLastEvaluatedKey extends SpvWalletError {
constructor() {
super(
'The last evaluated key has not changed between requests, indicating a possible loop or synchronization issue.',
);
}
}