pub fn map_provider_error(error: &ProviderError) -> (i32, &'static str)
Expand description
Maps provider errors to appropriate JSON-RPC error codes and messages.
This function translates internal provider errors into standardized JSON-RPC error codes and user-friendly messages that can be returned to clients. It follows JSON-RPC 2.0 specification for standard errors and uses OpenZeppelin-specific codes for extended functionality.
§Arguments
error
- A reference to the provider error to be mapped
§Returns
Returns a tuple containing:
i32
- The error code (following JSON-RPC 2.0 and OpenZeppelin conventions)&'static str
- A static string describing the error type
§Error Code Mappings
InvalidAddress
→ -32602 (“Invalid params”)NetworkConfiguration
→ -33004 (“Network configuration error”)Timeout
→ -33000 (“Request timeout”)RateLimited
→ -33001 (“Rate limited”)BadGateway
→ -33002 (“Bad gateway”)RequestError
→ -33003 (“Request error”)Other
and unknown errors → -32603 (“Internal error”)