fix(jsonrpc): propagate cancelled error in call

- CancelledError was being swallowed by except CatchableError
This commit is contained in:
Eric 2024-12-13 14:39:20 +11:00
parent 0f98528758
commit 1ba4b2c51e
No known key found for this signature in database

View File

@ -88,10 +88,16 @@ proc new*(
proc callImpl(
client: RpcClient,
call: string,
args: JsonNode): Future[JsonNode] {.async: (raises: [JsonRpcProviderError]).} =
args: JsonNode): Future[JsonNode] {.async: (raises: [CancelledError, JsonRpcProviderError]).} =
var response: JsonString
try:
response = await client.call(call, %args)
except CancelledError as e:
raise e
except CatchableError as e:
raiseJsonRpcProviderError e.msg
without response =? (await client.call(call, %args)).catch, error:
raiseJsonRpcProviderError error.msg
without json =? JsonNode.fromJson(response.string), error:
raiseJsonRpcProviderError "Failed to parse response: " & error.msg
json