Skip to content

Commit

Permalink
feat(sol-types): improve ABI decoding error messages (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jan 7, 2025
1 parent 03f007b commit f2280a5
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions crates/sol-types/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,22 @@ impl fmt::Display for Error {
Self::TypeCheckFail { expected_type, data } => {
write!(f, "type check failed for {expected_type:?} with data: {data}",)
}
Self::Overrun => f.write_str("buffer overrun while deserializing"),
Self::Reserve(e) => e.fmt(f),
Self::BufferNotEmpty => f.write_str("buffer not empty after deserialization"),
Self::ReserMismatch => f.write_str("reserialization did not match original"),
Self::RecursionLimitExceeded(limit) => {
write!(f, "recursion limit of {limit} exceeded during decoding")
Self::Overrun
| Self::BufferNotEmpty
| Self::ReserMismatch
| Self::RecursionLimitExceeded(_) => {
f.write_str("ABI decoding failed: ")?;
match *self {
Self::Overrun => f.write_str("buffer overrun while deserializing"),
Self::BufferNotEmpty => f.write_str("buffer not empty after deserialization"),
Self::ReserMismatch => f.write_str("reserialization did not match original"),
Self::RecursionLimitExceeded(limit) => {
write!(f, "recursion limit of {limit} exceeded during decoding")
}
_ => unreachable!(),
}
}
Self::Reserve(e) => e.fmt(f),
Self::InvalidEnumValue { name, value, max } => {
write!(f, "`{value}` is not a valid {name} enum value (max: `{max}`)")
}
Expand Down

0 comments on commit f2280a5

Please sign in to comment.