From 119ad0968b6ee1d518e44032c577ebacbf414789 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 15 Jan 2021 12:02:17 -0800 Subject: [PATCH] expose trap error from RuntimeError --- lib/engine/src/trap/error.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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 {