@injectivelabs/exceptions 1.15.0 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/exceptions/base.d.ts +76 -0
- package/dist/cjs/exceptions/base.js +175 -0
- package/dist/cjs/exceptions/exceptions/BitGetException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/BitGetException.js +23 -0
- package/dist/cjs/exceptions/exceptions/CosmosWalletException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/CosmosWalletException.js +16 -0
- package/dist/cjs/exceptions/exceptions/GeneralException.d.ts +5 -0
- package/dist/cjs/exceptions/exceptions/GeneralException.js +11 -0
- package/dist/cjs/exceptions/exceptions/GrpcUnaryRequestException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/GrpcUnaryRequestException.js +21 -0
- package/dist/cjs/exceptions/exceptions/HttpRequestException.d.ts +10 -0
- package/dist/cjs/exceptions/exceptions/HttpRequestException.js +21 -0
- package/dist/cjs/exceptions/exceptions/LedgerCosmosException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/LedgerCosmosException.js +40 -0
- package/dist/cjs/exceptions/exceptions/LedgerException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/LedgerException.js +40 -0
- package/dist/cjs/exceptions/exceptions/MetamaskException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/MetamaskException.js +23 -0
- package/dist/cjs/exceptions/exceptions/OkxWalletException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/OkxWalletException.js +23 -0
- package/dist/cjs/exceptions/exceptions/TransactionException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/TransactionException.js +26 -0
- package/dist/cjs/exceptions/exceptions/TrezorException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/TrezorException.js +16 -0
- package/dist/cjs/exceptions/exceptions/TrustWalletException.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/TrustWalletException.js +25 -0
- package/dist/cjs/exceptions/exceptions/WalletException.d.ts +5 -0
- package/dist/cjs/exceptions/exceptions/WalletException.js +11 -0
- package/dist/cjs/exceptions/exceptions/Web3Exception.d.ts +7 -0
- package/dist/cjs/exceptions/exceptions/Web3Exception.js +16 -0
- package/dist/cjs/exceptions/exceptions/index.d.ts +15 -0
- package/dist/cjs/exceptions/exceptions/index.js +31 -0
- package/dist/cjs/exceptions/index.d.ts +2 -0
- package/dist/cjs/exceptions/index.js +18 -0
- package/dist/cjs/exceptions/messages.d.ts +12 -0
- package/dist/cjs/exceptions/messages.js +1600 -0
- package/dist/cjs/exceptions/types/codes.d.ts +424 -0
- package/dist/cjs/exceptions/types/codes.js +791 -0
- package/dist/cjs/exceptions/types/context.d.ts +85 -0
- package/dist/cjs/exceptions/types/context.js +23 -0
- package/dist/cjs/exceptions/types/index.d.ts +3 -0
- package/dist/cjs/exceptions/types/index.js +19 -0
- package/dist/cjs/exceptions/types/modules.d.ts +59 -0
- package/dist/cjs/exceptions/types/modules.js +66 -0
- package/dist/cjs/exceptions/utils/grpc.d.ts +3 -0
- package/dist/cjs/exceptions/utils/grpc.js +40 -0
- package/dist/cjs/exceptions/utils/helpers.d.ts +1 -0
- package/dist/cjs/exceptions/utils/helpers.js +24 -0
- package/dist/cjs/exceptions/utils/maps.d.ts +13 -0
- package/dist/cjs/exceptions/utils/maps.js +132 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types.d.ts +2 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils.d.ts +8 -0
- package/dist/cjs/utils.js +47 -0
- package/dist/esm/exceptions/base.d.ts +76 -0
- package/dist/esm/exceptions/base.js +171 -0
- package/dist/esm/exceptions/exceptions/BitGetException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/BitGetException.js +19 -0
- package/dist/esm/exceptions/exceptions/CosmosWalletException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/CosmosWalletException.js +12 -0
- package/dist/esm/exceptions/exceptions/GeneralException.d.ts +5 -0
- package/dist/esm/exceptions/exceptions/GeneralException.js +7 -0
- package/dist/esm/exceptions/exceptions/GrpcUnaryRequestException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/GrpcUnaryRequestException.js +17 -0
- package/dist/esm/exceptions/exceptions/HttpRequestException.d.ts +10 -0
- package/dist/esm/exceptions/exceptions/HttpRequestException.js +17 -0
- package/dist/esm/exceptions/exceptions/LedgerCosmosException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/LedgerCosmosException.js +36 -0
- package/dist/esm/exceptions/exceptions/LedgerException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/LedgerException.js +36 -0
- package/dist/esm/exceptions/exceptions/MetamaskException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/MetamaskException.js +19 -0
- package/dist/esm/exceptions/exceptions/OkxWalletException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/OkxWalletException.js +19 -0
- package/dist/esm/exceptions/exceptions/TransactionException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/TransactionException.js +22 -0
- package/dist/esm/exceptions/exceptions/TrezorException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/TrezorException.js +12 -0
- package/dist/esm/exceptions/exceptions/TrustWalletException.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/TrustWalletException.js +21 -0
- package/dist/esm/exceptions/exceptions/WalletException.d.ts +5 -0
- package/dist/esm/exceptions/exceptions/WalletException.js +7 -0
- package/dist/esm/exceptions/exceptions/Web3Exception.d.ts +7 -0
- package/dist/esm/exceptions/exceptions/Web3Exception.js +12 -0
- package/dist/esm/exceptions/exceptions/index.d.ts +15 -0
- package/dist/esm/exceptions/exceptions/index.js +15 -0
- package/dist/esm/exceptions/index.d.ts +2 -0
- package/dist/esm/exceptions/index.js +2 -0
- package/dist/esm/exceptions/messages.d.ts +12 -0
- package/dist/esm/exceptions/messages.js +1597 -0
- package/dist/esm/exceptions/types/codes.d.ts +424 -0
- package/dist/esm/exceptions/types/codes.js +787 -0
- package/dist/esm/exceptions/types/context.d.ts +85 -0
- package/dist/esm/exceptions/types/context.js +20 -0
- package/dist/esm/exceptions/types/index.d.ts +3 -0
- package/dist/esm/exceptions/types/index.js +3 -0
- package/dist/esm/exceptions/types/modules.d.ts +59 -0
- package/dist/esm/exceptions/types/modules.js +63 -0
- package/dist/esm/exceptions/utils/grpc.d.ts +3 -0
- package/dist/esm/exceptions/utils/grpc.js +3 -0
- package/dist/esm/exceptions/utils/helpers.d.ts +1 -0
- package/dist/esm/exceptions/utils/helpers.js +20 -0
- package/dist/esm/exceptions/utils/maps.d.ts +13 -0
- package/dist/esm/exceptions/utils/maps.js +125 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/types.d.ts +2 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils.d.ts +8 -0
- package/dist/esm/utils.js +42 -0
- package/package.json +2 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Exception, ErrorType, ErrorContext, ErrorCode, ErrorContextCode } from './types/index.js';
|
|
2
|
+
export declare abstract class ConcreteException extends Error implements Exception {
|
|
3
|
+
/**
|
|
4
|
+
* The type of the Error
|
|
5
|
+
*/
|
|
6
|
+
type: ErrorType;
|
|
7
|
+
/**
|
|
8
|
+
* Error specific code (HttpStatus, GrpcStatus, etc)
|
|
9
|
+
*/
|
|
10
|
+
code: ErrorCode;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the error (the name of the instance of the Exception)
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* The name of the error (the name of the instance of the Exception)
|
|
17
|
+
* Needed for reporting reasons, ex: bugsnag
|
|
18
|
+
*/
|
|
19
|
+
errorClass: string;
|
|
20
|
+
/**
|
|
21
|
+
* Providing more context
|
|
22
|
+
* (ex: endpoint on http request)
|
|
23
|
+
*/
|
|
24
|
+
context?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Providing more context as to where the exception was thrown
|
|
27
|
+
* (ex: on-chain module, etc)
|
|
28
|
+
*/
|
|
29
|
+
contextModule?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Providing more context as to why the exception was thrown
|
|
32
|
+
* (ex: on-chain error code, etc)
|
|
33
|
+
*/
|
|
34
|
+
contextCode?: ErrorContextCode;
|
|
35
|
+
/**
|
|
36
|
+
* Parsed message of the exception
|
|
37
|
+
*/
|
|
38
|
+
message: string;
|
|
39
|
+
/**
|
|
40
|
+
* The original stack of the error
|
|
41
|
+
*/
|
|
42
|
+
stack?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The original message of the error
|
|
45
|
+
*/
|
|
46
|
+
originalMessage: string;
|
|
47
|
+
constructor(error: Error, context?: ErrorContext);
|
|
48
|
+
parse(): void;
|
|
49
|
+
parseError(error: Error): void;
|
|
50
|
+
parseContext(errorContext?: ErrorContext): void;
|
|
51
|
+
setType(type: ErrorType): void;
|
|
52
|
+
setCode(code: ErrorCode): void;
|
|
53
|
+
setContext(context: string): void;
|
|
54
|
+
setOriginalMessage(message: string): void;
|
|
55
|
+
setStack(stack: string): void;
|
|
56
|
+
setName(name: string): void;
|
|
57
|
+
setMessage(message: string): void;
|
|
58
|
+
setContextModule(contextModule: string): void;
|
|
59
|
+
setContextCode(code: ErrorContextCode): void;
|
|
60
|
+
toOriginalError(): Error;
|
|
61
|
+
toError(): Error;
|
|
62
|
+
toCompactError(): Error;
|
|
63
|
+
toJson(): string;
|
|
64
|
+
toObject(): {
|
|
65
|
+
code: ErrorCode;
|
|
66
|
+
type: ErrorType;
|
|
67
|
+
errorClass: string;
|
|
68
|
+
message: string;
|
|
69
|
+
context: string | undefined;
|
|
70
|
+
contextCode: ErrorContextCode | undefined;
|
|
71
|
+
contextModule: string | undefined;
|
|
72
|
+
originalMessage: string;
|
|
73
|
+
stack: string[];
|
|
74
|
+
};
|
|
75
|
+
toString(): string;
|
|
76
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConcreteException = void 0;
|
|
4
|
+
/* eslint-disable class-methods-use-this */
|
|
5
|
+
const index_js_1 = require("./types/index.js");
|
|
6
|
+
/**
|
|
7
|
+
* we have to define it here as
|
|
8
|
+
* well as in @injectivelabs/utils as that package is
|
|
9
|
+
* importing the exceptions package
|
|
10
|
+
* */
|
|
11
|
+
const toPascalCase = (str) => {
|
|
12
|
+
return `${str}`
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replace(new RegExp(/[-_]+/, 'g'), ' ')
|
|
15
|
+
.replace(new RegExp(/[^\w\s]/, 'g'), '')
|
|
16
|
+
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`)
|
|
17
|
+
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
|
|
18
|
+
};
|
|
19
|
+
class ConcreteException extends Error {
|
|
20
|
+
/**
|
|
21
|
+
* The type of the Error
|
|
22
|
+
*/
|
|
23
|
+
type = index_js_1.ErrorType.Unspecified;
|
|
24
|
+
/**
|
|
25
|
+
* Error specific code (HttpStatus, GrpcStatus, etc)
|
|
26
|
+
*/
|
|
27
|
+
code = index_js_1.UnspecifiedErrorCode;
|
|
28
|
+
/**
|
|
29
|
+
* The name of the error (the name of the instance of the Exception)
|
|
30
|
+
*/
|
|
31
|
+
name;
|
|
32
|
+
/**
|
|
33
|
+
* The name of the error (the name of the instance of the Exception)
|
|
34
|
+
* Needed for reporting reasons, ex: bugsnag
|
|
35
|
+
*/
|
|
36
|
+
errorClass;
|
|
37
|
+
/**
|
|
38
|
+
* Providing more context
|
|
39
|
+
* (ex: endpoint on http request)
|
|
40
|
+
*/
|
|
41
|
+
context;
|
|
42
|
+
/**
|
|
43
|
+
* Providing more context as to where the exception was thrown
|
|
44
|
+
* (ex: on-chain module, etc)
|
|
45
|
+
*/
|
|
46
|
+
contextModule;
|
|
47
|
+
/**
|
|
48
|
+
* Providing more context as to why the exception was thrown
|
|
49
|
+
* (ex: on-chain error code, etc)
|
|
50
|
+
*/
|
|
51
|
+
contextCode;
|
|
52
|
+
/**
|
|
53
|
+
* Parsed message of the exception
|
|
54
|
+
*/
|
|
55
|
+
message = '';
|
|
56
|
+
/**
|
|
57
|
+
* The original stack of the error
|
|
58
|
+
*/
|
|
59
|
+
stack = '';
|
|
60
|
+
/**
|
|
61
|
+
* The original message of the error
|
|
62
|
+
*/
|
|
63
|
+
originalMessage = '';
|
|
64
|
+
constructor(error, context) {
|
|
65
|
+
super(error.message);
|
|
66
|
+
this.parseError(error);
|
|
67
|
+
this.parseContext(context);
|
|
68
|
+
this.parse();
|
|
69
|
+
}
|
|
70
|
+
parse() {
|
|
71
|
+
//
|
|
72
|
+
}
|
|
73
|
+
parseError(error) {
|
|
74
|
+
this.setStack(error.stack || '');
|
|
75
|
+
this.setMessage(error.message);
|
|
76
|
+
this.originalMessage = error.message;
|
|
77
|
+
}
|
|
78
|
+
parseContext(errorContext) {
|
|
79
|
+
const { contextModule, type, code, context } = errorContext || {
|
|
80
|
+
contextModule: 'Unknown',
|
|
81
|
+
context: 'Unknown',
|
|
82
|
+
code: index_js_1.UnspecifiedErrorCode,
|
|
83
|
+
type: index_js_1.ErrorType.Unspecified,
|
|
84
|
+
};
|
|
85
|
+
this.context = context;
|
|
86
|
+
this.contextModule = contextModule;
|
|
87
|
+
this.type = type || index_js_1.ErrorType.Unspecified;
|
|
88
|
+
this.code = code || index_js_1.UnspecifiedErrorCode;
|
|
89
|
+
}
|
|
90
|
+
setType(type) {
|
|
91
|
+
this.type = type;
|
|
92
|
+
}
|
|
93
|
+
setCode(code) {
|
|
94
|
+
this.code = code;
|
|
95
|
+
}
|
|
96
|
+
setContext(context) {
|
|
97
|
+
this.context = context;
|
|
98
|
+
}
|
|
99
|
+
setOriginalMessage(message) {
|
|
100
|
+
this.originalMessage = message;
|
|
101
|
+
}
|
|
102
|
+
setStack(stack) {
|
|
103
|
+
try {
|
|
104
|
+
this.stack = stack;
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
// throw nothing here
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
setName(name) {
|
|
111
|
+
this.name = name;
|
|
112
|
+
this.errorClass = name;
|
|
113
|
+
super.name = name;
|
|
114
|
+
}
|
|
115
|
+
setMessage(message) {
|
|
116
|
+
this.message = message;
|
|
117
|
+
super.message = message;
|
|
118
|
+
}
|
|
119
|
+
setContextModule(contextModule) {
|
|
120
|
+
this.contextModule = contextModule;
|
|
121
|
+
}
|
|
122
|
+
setContextCode(code) {
|
|
123
|
+
this.contextCode = code;
|
|
124
|
+
}
|
|
125
|
+
toOriginalError() {
|
|
126
|
+
const error = new Error(this.originalMessage);
|
|
127
|
+
error.stack = this.stack;
|
|
128
|
+
error.name = this.name || '';
|
|
129
|
+
return error;
|
|
130
|
+
}
|
|
131
|
+
toError() {
|
|
132
|
+
const error = new Error(this.message);
|
|
133
|
+
error.stack = this.stack;
|
|
134
|
+
error.name = this.name || '';
|
|
135
|
+
return error;
|
|
136
|
+
}
|
|
137
|
+
toCompactError() {
|
|
138
|
+
const name = this.name || toPascalCase(this.type);
|
|
139
|
+
const error = new Error(`${this.message} | ${JSON.stringify({
|
|
140
|
+
type: this.type,
|
|
141
|
+
code: this.code,
|
|
142
|
+
errorClass: name,
|
|
143
|
+
message: this.message,
|
|
144
|
+
context: this.context,
|
|
145
|
+
contextCode: this.contextCode,
|
|
146
|
+
contextModule: this.contextModule,
|
|
147
|
+
originalMessage: this.originalMessage,
|
|
148
|
+
stack: (this.stack || '').split('\n').map((line) => line.trim()),
|
|
149
|
+
})}`);
|
|
150
|
+
error.stack = this.stack;
|
|
151
|
+
error.name = this.name || toPascalCase(this.type);
|
|
152
|
+
return error;
|
|
153
|
+
}
|
|
154
|
+
toJson() {
|
|
155
|
+
return JSON.stringify({ error: this.message, stack: this.stack });
|
|
156
|
+
}
|
|
157
|
+
toObject() {
|
|
158
|
+
const name = this.name || toPascalCase(this.type);
|
|
159
|
+
return {
|
|
160
|
+
code: this.code,
|
|
161
|
+
type: this.type,
|
|
162
|
+
errorClass: name,
|
|
163
|
+
message: this.message,
|
|
164
|
+
context: this.context,
|
|
165
|
+
contextCode: this.contextCode,
|
|
166
|
+
contextModule: this.contextModule,
|
|
167
|
+
originalMessage: this.originalMessage,
|
|
168
|
+
stack: (this.stack || '').split('\n').map((line) => line.trim()),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
toString() {
|
|
172
|
+
return this.message;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.ConcreteException = ConcreteException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class BitGetException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitGetException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
const maps_js_1 = require("../utils/maps.js");
|
|
7
|
+
const removeBitGetFromErrorString = (message) => message
|
|
8
|
+
.replaceAll('BitGet', '')
|
|
9
|
+
.replaceAll('Bitget:', '')
|
|
10
|
+
.replaceAll('Bitkeep:', '');
|
|
11
|
+
class BitGetException extends base_js_1.ConcreteException {
|
|
12
|
+
static errorClass = 'BitGetException';
|
|
13
|
+
constructor(error, context) {
|
|
14
|
+
super(error, context);
|
|
15
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
16
|
+
}
|
|
17
|
+
parse() {
|
|
18
|
+
const { message } = this;
|
|
19
|
+
this.setName(BitGetException.errorClass);
|
|
20
|
+
this.setMessage((0, maps_js_1.mapMetamaskMessage)(removeBitGetFromErrorString(message)));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.BitGetException = BitGetException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class CosmosWalletException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CosmosWalletException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
class CosmosWalletException extends base_js_1.ConcreteException {
|
|
7
|
+
static errorClass = 'CosmosWalletException';
|
|
8
|
+
constructor(error, context) {
|
|
9
|
+
super(error, context);
|
|
10
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
11
|
+
}
|
|
12
|
+
parse() {
|
|
13
|
+
this.setName(CosmosWalletException.errorClass);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.CosmosWalletException = CosmosWalletException;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeneralException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
class GeneralException extends base_js_1.ConcreteException {
|
|
6
|
+
static errorClass = 'GeneralException';
|
|
7
|
+
parse() {
|
|
8
|
+
this.setName(GeneralException.errorClass);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.GeneralException = GeneralException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class GrpcUnaryRequestException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GrpcUnaryRequestException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
class GrpcUnaryRequestException extends base_js_1.ConcreteException {
|
|
7
|
+
static errorClass = 'GrpcUnaryRequestException';
|
|
8
|
+
constructor(error, context) {
|
|
9
|
+
super(error, context);
|
|
10
|
+
this.type = index_js_1.ErrorType.GrpcUnaryRequest;
|
|
11
|
+
}
|
|
12
|
+
parse() {
|
|
13
|
+
const { message } = this;
|
|
14
|
+
if (message.toLowerCase().includes('response closed without headers')) {
|
|
15
|
+
this.setMessage('The request has failed. The server has closed the connection without sending any headers.');
|
|
16
|
+
this.setContextCode(index_js_1.GRPC_REQUEST_FAILED);
|
|
17
|
+
}
|
|
18
|
+
this.setName(GrpcUnaryRequestException.errorClass);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.GrpcUnaryRequestException = GrpcUnaryRequestException;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext, HttpRequestMethod } from '../types/index.js';
|
|
3
|
+
export declare class HttpRequestException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
method: HttpRequestMethod;
|
|
6
|
+
constructor(error: Error, context?: ErrorContext & {
|
|
7
|
+
method?: HttpRequestMethod;
|
|
8
|
+
});
|
|
9
|
+
parse(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpRequestException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
class HttpRequestException extends base_js_1.ConcreteException {
|
|
7
|
+
static errorClass = 'HttpRequestException';
|
|
8
|
+
method = index_js_1.HttpRequestMethod.Get;
|
|
9
|
+
constructor(error, context) {
|
|
10
|
+
super(error, context);
|
|
11
|
+
this.type = index_js_1.ErrorType.HttpRequest;
|
|
12
|
+
this.method = context
|
|
13
|
+
? context.method || index_js_1.HttpRequestMethod.Get
|
|
14
|
+
: index_js_1.HttpRequestMethod.Get;
|
|
15
|
+
this.context = context?.context || 'Unknown';
|
|
16
|
+
}
|
|
17
|
+
parse() {
|
|
18
|
+
this.setName(HttpRequestException.errorClass);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.HttpRequestException = HttpRequestException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class LedgerCosmosException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LedgerCosmosException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
const helpers_js_1 = require("../utils/helpers.js");
|
|
7
|
+
class LedgerCosmosException extends base_js_1.ConcreteException {
|
|
8
|
+
static errorClass = 'LedgerCosmosException';
|
|
9
|
+
constructor(error, context) {
|
|
10
|
+
super(error, context);
|
|
11
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
12
|
+
}
|
|
13
|
+
parse() {
|
|
14
|
+
const { message } = this;
|
|
15
|
+
if ((0, helpers_js_1.isCommonLockedError)(message)) {
|
|
16
|
+
this.setMessage('Please ensure your Ledger is connected, unlocked and your Cosmos app is open.');
|
|
17
|
+
}
|
|
18
|
+
if (message.includes('No device selected.')) {
|
|
19
|
+
this.setMessage('Please make sure your Ledger device is connected, unlocked and your Cosmos app is open');
|
|
20
|
+
}
|
|
21
|
+
if (message.includes('Unable to set device configuration.')) {
|
|
22
|
+
this.setMessage('Please restart your Ledger device and try connecting again');
|
|
23
|
+
}
|
|
24
|
+
if (message.includes('Cannot read properties of undefined')) {
|
|
25
|
+
this.setMessage('Please make sure your Ledger device is connected');
|
|
26
|
+
}
|
|
27
|
+
if (message.toLowerCase().includes('locked')) {
|
|
28
|
+
this.setMessage('Please make sure your Ledger device is connected, unlocked and your Cosmos app is open');
|
|
29
|
+
}
|
|
30
|
+
if (message.includes('Condition of use not satisfied') ||
|
|
31
|
+
message.includes('0x6985')) {
|
|
32
|
+
this.setMessage('The request has been rejected');
|
|
33
|
+
}
|
|
34
|
+
if (message.includes('U2F browser support is needed for Ledger.')) {
|
|
35
|
+
this.setMessage('Please use the latest Chrome/Firefox browser versions to connect with your Ledger device');
|
|
36
|
+
}
|
|
37
|
+
this.setName(LedgerCosmosException.errorClass);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.LedgerCosmosException = LedgerCosmosException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class LedgerException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LedgerException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
const helpers_js_1 = require("../utils/helpers.js");
|
|
7
|
+
class LedgerException extends base_js_1.ConcreteException {
|
|
8
|
+
static errorClass = 'LedgerException';
|
|
9
|
+
constructor(error, context) {
|
|
10
|
+
super(error, context);
|
|
11
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
12
|
+
}
|
|
13
|
+
parse() {
|
|
14
|
+
const { message } = this;
|
|
15
|
+
if ((0, helpers_js_1.isCommonLockedError)(message)) {
|
|
16
|
+
this.setMessage('Please ensure your Ledger is connected, unlocked and your Ethereum app is open.');
|
|
17
|
+
}
|
|
18
|
+
if (message.includes('No device selected.')) {
|
|
19
|
+
this.setMessage('Please make sure your Ledger device is connected, unlocked and your Ethereum app is open');
|
|
20
|
+
}
|
|
21
|
+
if (message.includes('Unable to set device configuration.')) {
|
|
22
|
+
this.setMessage('Please restart your Ledger device and try connecting again');
|
|
23
|
+
}
|
|
24
|
+
if (message.includes('Cannot read properties of undefined')) {
|
|
25
|
+
this.setMessage('Please make sure your Ledger device is connected');
|
|
26
|
+
}
|
|
27
|
+
if (message.toLowerCase().includes('locked')) {
|
|
28
|
+
this.setMessage('Please make sure your Ledger device is connected, unlocked and your Ethereum app is open');
|
|
29
|
+
}
|
|
30
|
+
if (message.includes('Condition of use not satisfied') ||
|
|
31
|
+
message.includes('0x6985')) {
|
|
32
|
+
this.setMessage('The request has been rejected');
|
|
33
|
+
}
|
|
34
|
+
if (message.includes('U2F browser support is needed for Ledger.')) {
|
|
35
|
+
this.setMessage('Please use the latest Chrome/Firefox browser versions to connect with your Ledger device');
|
|
36
|
+
}
|
|
37
|
+
this.setName(LedgerException.errorClass);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.LedgerException = LedgerException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class MetamaskException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetamaskException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
const maps_js_1 = require("../utils/maps.js");
|
|
7
|
+
const removeMetamaskFromErrorString = (message) => message
|
|
8
|
+
.replaceAll('Metamask', '')
|
|
9
|
+
.replaceAll('MetaMask', '')
|
|
10
|
+
.replaceAll('Metamask:', '');
|
|
11
|
+
class MetamaskException extends base_js_1.ConcreteException {
|
|
12
|
+
static errorClass = 'MetamaskException';
|
|
13
|
+
constructor(error, context) {
|
|
14
|
+
super(error, context);
|
|
15
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
16
|
+
}
|
|
17
|
+
parse() {
|
|
18
|
+
const { message } = this;
|
|
19
|
+
this.setMessage((0, maps_js_1.mapMetamaskMessage)(removeMetamaskFromErrorString(message)));
|
|
20
|
+
this.setName(MetamaskException.errorClass);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.MetamaskException = MetamaskException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class OkxWalletException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OkxWalletException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
const maps_js_1 = require("../utils/maps.js");
|
|
7
|
+
const removeOkxWalletFromErrorString = (message) => message
|
|
8
|
+
.replaceAll('OkxWallet', '')
|
|
9
|
+
.replaceAll('Okx', '')
|
|
10
|
+
.replaceAll('OkxWallet:', '');
|
|
11
|
+
class OkxWalletException extends base_js_1.ConcreteException {
|
|
12
|
+
static errorClass = 'OkxWalletException';
|
|
13
|
+
constructor(error, context) {
|
|
14
|
+
super(error, context);
|
|
15
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
16
|
+
}
|
|
17
|
+
parse() {
|
|
18
|
+
const { message } = this;
|
|
19
|
+
this.setMessage((0, maps_js_1.mapMetamaskMessage)(removeOkxWalletFromErrorString(message)));
|
|
20
|
+
this.setName(OkxWalletException.errorClass);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.OkxWalletException = OkxWalletException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class TransactionException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
const maps_js_1 = require("../utils/maps.js");
|
|
7
|
+
class TransactionException extends base_js_1.ConcreteException {
|
|
8
|
+
static errorClass = 'TransactionException';
|
|
9
|
+
constructor(error, context) {
|
|
10
|
+
super(error, context);
|
|
11
|
+
this.type = index_js_1.ErrorType.ChainError;
|
|
12
|
+
}
|
|
13
|
+
parse() {
|
|
14
|
+
const { message, context, contextModule, contextCode } = this;
|
|
15
|
+
const { code, message: parsedMessage, contextModule: parsedContextModule, } = (0, maps_js_1.mapFailedTransactionMessage)(message, { contextCode, contextModule });
|
|
16
|
+
this.setContext(context || 'Unknown');
|
|
17
|
+
this.setMessage(parsedMessage);
|
|
18
|
+
this.setContextCode(code);
|
|
19
|
+
this.setOriginalMessage((0, maps_js_1.parseErrorMessage)(message));
|
|
20
|
+
if (parsedContextModule) {
|
|
21
|
+
this.setContextModule(parsedContextModule);
|
|
22
|
+
}
|
|
23
|
+
this.setName(TransactionException.errorClass);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.TransactionException = TransactionException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class TrezorException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrezorException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
class TrezorException extends base_js_1.ConcreteException {
|
|
7
|
+
static errorClass = 'TrezorException';
|
|
8
|
+
constructor(error, context) {
|
|
9
|
+
super(error, context);
|
|
10
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
11
|
+
}
|
|
12
|
+
parse() {
|
|
13
|
+
this.setName(TrezorException.errorClass);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.TrezorException = TrezorException;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConcreteException } from '../base.js';
|
|
2
|
+
import { ErrorContext } from '../types/index.js';
|
|
3
|
+
export declare class TrustWalletException extends ConcreteException {
|
|
4
|
+
static errorClass: string;
|
|
5
|
+
constructor(error: Error, context?: ErrorContext);
|
|
6
|
+
parse(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrustWalletException = void 0;
|
|
4
|
+
const base_js_1 = require("../base.js");
|
|
5
|
+
const index_js_1 = require("../types/index.js");
|
|
6
|
+
const maps_js_1 = require("../utils/maps.js");
|
|
7
|
+
const removeTrustWalletFromErrorString = (message) => message
|
|
8
|
+
.replaceAll('TrustWallet', '')
|
|
9
|
+
.replaceAll('Trust Wallet', '')
|
|
10
|
+
.replaceAll('Trustwallet', '')
|
|
11
|
+
.replaceAll('TrustWallet:', '')
|
|
12
|
+
.replaceAll('Trust Wallet:', '');
|
|
13
|
+
class TrustWalletException extends base_js_1.ConcreteException {
|
|
14
|
+
static errorClass = 'TrustWalletException';
|
|
15
|
+
constructor(error, context) {
|
|
16
|
+
super(error, context);
|
|
17
|
+
this.type = index_js_1.ErrorType.WalletError;
|
|
18
|
+
}
|
|
19
|
+
parse() {
|
|
20
|
+
const { message } = this;
|
|
21
|
+
this.setMessage((0, maps_js_1.mapMetamaskMessage)(removeTrustWalletFromErrorString(message)));
|
|
22
|
+
this.setName(TrustWalletException.errorClass);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.TrustWalletException = TrustWalletException;
|