*Better catch rpc node errors and ensure they are passed through properly to the client

This commit is contained in:
Derrick Hammer 2022-07-25 23:09:26 -04:00
parent 9a9a888bcb
commit d3a90c7714
1 changed files with 14 additions and 1 deletions

View File

@ -68,7 +68,20 @@ export function proxyRpcMethod(
provider = getRpcProvider(chainId as string); provider = getRpcProvider(chainId as string);
} }
gatewayProviders[chainId as string] = provider; gatewayProviders[chainId as string] = provider;
return await provider(method, args);
let resp;
try {
resp = await provider(method, args);
} catch (e: any) {
e = e as Error;
if ("error" in e) {
return e.error;
}
return e;
}
return resp;
} }
return await sendRelay( return await sendRelay(