File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,16 @@ type NetworkOpts = {
217217} ;
218218
219219type RpcParams = any [ ] | Record < string , any > ;
220- type RpcError = { code : number ; message : string } ;
220+ type RpcErrorResponse = { code : number ; message : string } ;
221+
222+ export class RpcError extends Error {
223+ readonly code : number ;
224+ constructor ( error : RpcErrorResponse ) {
225+ super ( `FetchProvider(${ error . code } ): ${ error . message || error } ` ) ;
226+ this . code = error . code ;
227+ this . name = 'RpcError' ;
228+ }
229+ }
221230
222231/**
223232 * Small utility class for Jsonrpc
@@ -256,8 +265,8 @@ export class JsonrpcProvider implements JsonrpcInterface {
256265 } ) ;
257266 return await res . json ( ) ;
258267 }
259- private jsonError ( error : RpcError ) {
260- return new Error ( `FetchProvider( ${ error . code } ): ${ error . message || error } ` ) ;
268+ private jsonError ( error : RpcErrorResponse ) {
269+ return new RpcError ( error ) ;
261270 }
262271 private async batchProcess ( ) {
263272 await nextTick ( ) ; // this allows to collect as much requests as we can in single tick
You can’t perform that action at this time.
0 commit comments