# Parsing custom contract errors

**URL:** <https://forum.fuel.network/t/parsing-custom-contract-errors/9478>\
**Category:** Rust SDK\
**Created:** [July 29, 2025, 7:32pm UTC](https://forum.fuel.network/t/parsing-custom-contract-errors/9478 "2025-07-29T19:32:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenryMBaldwin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/henrymbaldwin/32/4177_2.png) [@HenryMBaldwin](https://forum.fuel.network/u/HenryMBaldwin)\
**Post date:** [July 29, 2025, 7:32pm UTC](https://forum.fuel.network/t/parsing-custom-contract-errors/9478/1 "2025-07-29T19:32:28Z")

</div>

I am hitting a contract that follows an error emitting pattern like:

`log(CustomError::ErrorOne)`  
`revert(0)`

where `CustomError` is defined as:

`pub enum CustomError {`  
` ErrorOne: (),`  
` ErrorTwo: (),`  
` …`  
`}`

In rust code, when calling a function (either by `call()` or `simulate()`) I sometimes see these reversions, as I would expect. In these cases, I am just given an Err() result with some log data. Is there a trivial way to detect and parse out my custom errors from this? Of course, I may not actually see my custom error and it may be an unrelated reversion/error, so ideally it’s easy to distinguish that too.

---

<div class="post-metadata">

**Author:** ![HenryMBaldwin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/henrymbaldwin/32/4177_2.png) [@HenryMBaldwin](https://forum.fuel.network/u/HenryMBaldwin)\
**Post date:** [July 31, 2025, 2:17pm UTC](https://forum.fuel.network/t/parsing-custom-contract-errors/9478/2 "2025-07-31T14:17:41Z")

</div>

I have updated my contract to use the new #[error\_type] #[error] and panic, but my question largely remains the same.

---

<div class="post-metadata">

**Author:** ![HenryMBaldwin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/henrymbaldwin/32/4177_2.png) [@HenryMBaldwin](https://forum.fuel.network/u/HenryMBaldwin)\
**Post date:** [August 1, 2025, 8:48pm UTC](https://forum.fuel.network/t/parsing-custom-contract-errors/9478/3 "2025-08-01T20:48:56Z")

</div>

Turns out decoding logs from a reversion with `decode_logs_with_type::<AbigenErrorType>(&receipts)` does the trick!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [August 22, 2025, 4:48pm UTC](https://forum.fuel.network/t/parsing-custom-contract-errors/9478/4 "2025-08-22T16:48:58Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
