pub fn parse_custom_error(output: &[u8]) -> Option<String>Expand description
Parse custom error output from a failed transaction
Handles two main types of errors:
- Error(string) - Standard revert with message (selector: 0x08c379a0)
- Panic(uint256) - Solidity panic with error code (selector: 0x4e487b71)
§Arguments
output- Raw error output bytes from the failed transaction
§Returns
Some(String)- Decoded error message or panic reasonNone- If the error format is not recognized or cannot be decoded
§Example
use revm_trace::utils::error_utils::parse_custom_error;
use alloy::primitives::hex;
let error_output = hex::decode("08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000014496e73756666696369656e742062616c616e636500000000000000000000000000").unwrap();
let error_message = parse_custom_error(&error_output);
assert_eq!(error_message, Some("Insufficient balance".to_string()));