---
# System prepended metadata

title: Error handling for Substrate runtime APIs exposed through the `state_call` RPC
tags: [' substrate', evergreen-note]

---



When implementing a runtime API that will be called through the `state_call` RPC, what are the best practices for error handling? For example, consider that the runtime API call may fail (e.g. account in the params doesn't exist), what should be returned in the runtime trait method? *Option 1*: the method returns a `Result<T, E>`; or *option 2*, the method returns `T` and handles a potential error with an `unwrap_or_default()` (or similar) in the runtime API implementation?
 
*Testing manually*: When returning the result, the RPC call result is `0x00000000000000000000000000000000`. When handling the error with `unwrap_or_default()` the result is `0x01`. I wonder what's the best option here, but tbh the `0x0...0` looks more correct to me.
