From 18c5c3fd34ceb8a1631f7766b69e407cf92e1a09 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 15 May 2026 21:54:11 +0800 Subject: Add panic catch for program execution --- mingling_core/src/program/error.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 mingling_core/src/program/error.rs (limited to 'mingling_core/src/program/error.rs') diff --git a/mingling_core/src/program/error.rs b/mingling_core/src/program/error.rs new file mode 100644 index 0000000..5e92a42 --- /dev/null +++ b/mingling_core/src/program/error.rs @@ -0,0 +1,22 @@ +use std::any::Any; +use std::fmt; +use thiserror::Error; + +/// Error type returned when a panic occurs during execution. +#[derive(Error)] +#[error("execution panicked: {payload:?}")] +pub struct ProgramPanic { + pub payload: Box, +} + +impl ProgramPanic { + pub fn new(payload: Box) -> Self { + ProgramPanic { payload } + } +} + +impl fmt::Debug for ProgramPanic { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self.payload) + } +} -- cgit