Skip to content

Commit

Permalink
expose trap error from RuntimeError
Browse files Browse the repository at this point in the history
  • Loading branch information
ailisp committed Jan 15, 2021
1 parent 4edbde8 commit 119ad09
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/engine/src/trap/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ impl RuntimeError {
}
}

/// Returns trap code, if it's a Trap
pub fn to_trap(self) -> Option<TrapCode> {
if let RuntimeErrorSource::Trap(trap_code) = self.inner.source {
Some(trap_code)
} else {
None
}
}

/// Returns true if the `RuntimeError` is the same as T
pub fn is<T: Error + 'static>(&self) -> bool {
match &self.inner.source {
Expand Down

0 comments on commit 119ad09

Please sign in to comment.