MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / error_with_data

Function error_with_data

fendermint/eth/api/src/error.rs:61–75  ·  view source on GitHub ↗
(
    exit_code: ExitCode,
    msg: impl ToString,
    data: Option<E>,
)

Source from the content-addressed store, hash-verified

59}
60
61pub 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

Callers 1

error_with_revertFunction · 0.85

Calls 1

to_stringMethod · 0.80

Tested by

no test coverage detected