Preserve error type when RPC fails

pull/3566/head
James Campbell 2024-12-06 14:42:27 +01:00
parent e8f97395b4
commit f0f13e20ec
No known key found for this signature in database
1 changed files with 3 additions and 10 deletions

View File

@ -35,7 +35,6 @@ from nucypher.policy.conditions.context import (
)
from nucypher.policy.conditions.exceptions import (
NoConnectionToChain,
RPCExecutionFailed,
)
from nucypher.policy.conditions.lingo import (
ConditionType,
@ -188,13 +187,9 @@ class RPCCall(ExecutionCall):
result = self._execute_with_provider(provider, resolved_parameters)
return result
except Exception as e:
latest_error = str(e)
latest_error = e
continue
raise RPCExecutionFailed(
f"RPC call '{self.method}' failed; latest error - {latest_error}"
)
# Try custom RPC endpoint if provided
if self.rpc_endpoint:
try:
@ -203,13 +198,11 @@ class RPCCall(ExecutionCall):
)
return result
except Exception as e:
latest_error = str(e)
latest_error = e
# If we get here, all attempts failed
if latest_error:
raise RPCExecutionFailed(
f"RPC call '{self.method}' failed; latest error - {latest_error}"
)
raise latest_error
raise NoConnectionToChain(chain=self.chain)
def _execute(self, w3: Web3, resolved_parameters: List[Any]) -> Any: