(
exit_code: ExitCode,
msg: impl ToString,
data: Option<E>,
)
| 59 | } |
| 60 | |
| 61 | pub fn error_with_data<T, E: Serialize>( |
| 62 | exit_code: ExitCode, |
| 63 | msg: impl ToString, |
| 64 | data: Option<E>, |
| 65 | ) -> Result<T, JsonRpcError> { |
| 66 | let data = data.map(|data| match serde_json::to_value(data) { |
| 67 | Ok(v) => v, |
| 68 | Err(e) => serde_json::Value::String(format!("failed to serialize error data: {e}")), |
| 69 | }); |
| 70 | Err(JsonRpcError { |
| 71 | code: exit_code.value().into(), |
| 72 | message: msg.to_string(), |
| 73 | data, |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | /// Try to parse the data returned from the EVM as a revert string and append it to the message, |
| 78 | /// so we have a bit more human readable feedback than just hexadecimal strings with the selector |
no test coverage detected