Skip to content

Commit

Permalink
Added wider error deetection for JSON-RPC unsupported operation (#4162).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jun 27, 2023
1 parent 3d141b4 commit 1dc8986
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src.ts/providers/provider-jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,13 +961,20 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
}
}

if (message.match(/the method .* does not exist/i)) {
let unsupported = !!message.match(/the method .* does not exist/i);
if (!unsupported) {
if (error && (<any>error).details && (<any>error).details.startsWith("Unauthorized method:")) {
unsupported = true;
}
}

if (unsupported) {
return makeError("unsupported operation", "UNSUPPORTED_OPERATION", {
operation: payload.method, info: { error }
operation: payload.method, info: { error, payload }
});
}

return makeError("could not coalesce error", "UNKNOWN_ERROR", { error });
return makeError("could not coalesce error", "UNKNOWN_ERROR", { error, payload });

This comment has been minimized.

Copy link
@therealjmj

therealjmj Jun 28, 2023

Better!
The piece that's still missing is [which] RPC URL (and which network) is erroring.
This is helpful for complex FallbackProvider setups.

}


Expand Down

0 comments on commit 1dc8986

Please # to comment.