diff --git a/lib/engine/src/trap/error.rs b/lib/engine/src/trap/error.rs index c7811aa082a..36cdb7e49bc 100644 --- a/lib/engine/src/trap/error.rs +++ b/lib/engine/src/trap/error.rs @@ -207,6 +207,15 @@ impl RuntimeError { } } + /// Returns trap code, if it's a Trap + pub fn to_trap(self) -> Option { + 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(&self) -> bool { match &self.inner.source {