@injectivelabs/exceptions 1.16.13-alpha.6 → 1.16.14
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 +4 -0
- package/dist/cjs/exceptions/base.js +5 -0
- package/dist/cjs/exceptions/exceptions/TransactionException.js +8 -0
- package/dist/cjs/exceptions/types/context.d.ts +6 -0
- package/dist/esm/exceptions/base.d.ts +4 -0
- package/dist/esm/exceptions/base.js +5 -0
- package/dist/esm/exceptions/exceptions/TransactionException.js +8 -0
- package/dist/esm/exceptions/types/context.d.ts +6 -0
- package/package.json +2 -2
|
@@ -45,6 +45,10 @@ export declare abstract class ConcreteException extends Error implements Excepti
|
|
|
45
45
|
* The original message of the error
|
|
46
46
|
*/
|
|
47
47
|
originalMessage: string;
|
|
48
|
+
/**
|
|
49
|
+
* Flag to skip parsing the error message
|
|
50
|
+
*/
|
|
51
|
+
protected skipParsing: boolean;
|
|
48
52
|
constructor(error: Error, context?: ErrorContext);
|
|
49
53
|
parse(): void;
|
|
50
54
|
parseError(error: Error): void;
|
|
@@ -60,8 +60,13 @@ class ConcreteException extends Error {
|
|
|
60
60
|
* The original message of the error
|
|
61
61
|
*/
|
|
62
62
|
originalMessage = '';
|
|
63
|
+
/**
|
|
64
|
+
* Flag to skip parsing the error message
|
|
65
|
+
*/
|
|
66
|
+
skipParsing = false;
|
|
63
67
|
constructor(error, context) {
|
|
64
68
|
super(error.message);
|
|
69
|
+
this.skipParsing = context?.skipParsing || false;
|
|
65
70
|
this.parseError(error);
|
|
66
71
|
this.parseContext(context);
|
|
67
72
|
this.parse();
|
|
@@ -12,6 +12,14 @@ class TransactionException extends base_js_1.ConcreteException {
|
|
|
12
12
|
}
|
|
13
13
|
parse() {
|
|
14
14
|
const { message, context, contextModule, contextCode } = this;
|
|
15
|
+
// If skipParsing is true, just use the raw message
|
|
16
|
+
if (this.skipParsing) {
|
|
17
|
+
this.setContext(context || 'Unknown');
|
|
18
|
+
this.setMessage(message);
|
|
19
|
+
this.setOriginalMessage(message);
|
|
20
|
+
this.setName(TransactionException.errorClass);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
15
23
|
const { code, message: parsedMessage, contextModule: parsedContextModule, } = (0, maps_js_1.mapFailedTransactionMessage)(message, { contextCode, contextModule });
|
|
16
24
|
this.setContext(context || 'Unknown');
|
|
17
25
|
this.setMessage(parsedMessage);
|
|
@@ -36,6 +36,12 @@ export interface ErrorContext {
|
|
|
36
36
|
* for example why the transaction has failed
|
|
37
37
|
* */
|
|
38
38
|
contextCode?: ErrorContextCode;
|
|
39
|
+
/**
|
|
40
|
+
* If true, skip parsing the error message and use the raw message
|
|
41
|
+
* Useful when you want to preserve the original error message without
|
|
42
|
+
* any transformation or mapping
|
|
43
|
+
*/
|
|
44
|
+
skipParsing?: boolean;
|
|
39
45
|
}
|
|
40
46
|
export interface Exception {
|
|
41
47
|
/**
|
|
@@ -45,6 +45,10 @@ export declare abstract class ConcreteException extends Error implements Excepti
|
|
|
45
45
|
* The original message of the error
|
|
46
46
|
*/
|
|
47
47
|
originalMessage: string;
|
|
48
|
+
/**
|
|
49
|
+
* Flag to skip parsing the error message
|
|
50
|
+
*/
|
|
51
|
+
protected skipParsing: boolean;
|
|
48
52
|
constructor(error: Error, context?: ErrorContext);
|
|
49
53
|
parse(): void;
|
|
50
54
|
parseError(error: Error): void;
|
|
@@ -57,8 +57,13 @@ export class ConcreteException extends Error {
|
|
|
57
57
|
* The original message of the error
|
|
58
58
|
*/
|
|
59
59
|
originalMessage = '';
|
|
60
|
+
/**
|
|
61
|
+
* Flag to skip parsing the error message
|
|
62
|
+
*/
|
|
63
|
+
skipParsing = false;
|
|
60
64
|
constructor(error, context) {
|
|
61
65
|
super(error.message);
|
|
66
|
+
this.skipParsing = context?.skipParsing || false;
|
|
62
67
|
this.parseError(error);
|
|
63
68
|
this.parseContext(context);
|
|
64
69
|
this.parse();
|
|
@@ -9,6 +9,14 @@ export class TransactionException extends ConcreteException {
|
|
|
9
9
|
}
|
|
10
10
|
parse() {
|
|
11
11
|
const { message, context, contextModule, contextCode } = this;
|
|
12
|
+
// If skipParsing is true, just use the raw message
|
|
13
|
+
if (this.skipParsing) {
|
|
14
|
+
this.setContext(context || 'Unknown');
|
|
15
|
+
this.setMessage(message);
|
|
16
|
+
this.setOriginalMessage(message);
|
|
17
|
+
this.setName(TransactionException.errorClass);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
12
20
|
const { code, message: parsedMessage, contextModule: parsedContextModule, } = mapFailedTransactionMessage(message, { contextCode, contextModule });
|
|
13
21
|
this.setContext(context || 'Unknown');
|
|
14
22
|
this.setMessage(parsedMessage);
|
|
@@ -36,6 +36,12 @@ export interface ErrorContext {
|
|
|
36
36
|
* for example why the transaction has failed
|
|
37
37
|
* */
|
|
38
38
|
contextCode?: ErrorContextCode;
|
|
39
|
+
/**
|
|
40
|
+
* If true, skip parsing the error message and use the raw message
|
|
41
|
+
* Useful when you want to preserve the original error message without
|
|
42
|
+
* any transformation or mapping
|
|
43
|
+
*/
|
|
44
|
+
skipParsing?: boolean;
|
|
39
45
|
}
|
|
40
46
|
export interface Exception {
|
|
41
47
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/exceptions",
|
|
3
3
|
"description": "List of exceptions that can be reused throughout Injective's projects.",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.14",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"shx": "^0.3.4"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "01870962a21e75a31d5eeef1200544597281bfea"
|
|
65
65
|
}
|