Skip to content

Commit 30ffa78

Browse files
committed
Added extra details in the error info field for RPC errors.
1 parent 6e01e54 commit 30ffa78

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src.ts/providers/provider-jsonrpc.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
415415

416416
// No result; the node failed us in unexpected ways
417417
if (resp == null) {
418-
return reject(new Error("@TODO: no result"));
418+
return reject(makeError("no response from server", "BAD_DATA", { value: result, info: { payload } }));
419419
}
420420

421421
// The response is an error
@@ -797,6 +797,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
797797
if (!msg.match(/revert/i) && msg.match(/insufficient funds/i)) {
798798
return makeError("insufficient funds", "INSUFFICIENT_FUNDS", {
799799
transaction: ((<any>payload).params[0]),
800+
info: { payload, error }
800801
});
801802
}
802803
}
@@ -846,17 +847,17 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
846847
}
847848

848849
if (message.match(/nonce/i) && message.match(/too low/i)) {
849-
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction });
850+
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction, info: { error } });
850851
}
851852

852853
// "replacement transaction underpriced"
853854
if (message.match(/replacement transaction/i) && message.match(/underpriced/i)) {
854-
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction });
855+
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction, info: { error } });
855856
}
856857

857858
if (message.match(/only replay-protected/i)) {
858859
return makeError("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", {
859-
operation: method, info: { transaction }
860+
operation: method, info: { transaction, info: { error } }
860861
});
861862
}
862863
}

0 commit comments

Comments
 (0)