aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/program')
-rw-r--r--mingling_core/src/program/error.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/mingling_core/src/program/error.rs b/mingling_core/src/program/error.rs
index 5e92a42..a6874cf 100644
--- a/mingling_core/src/program/error.rs
+++ b/mingling_core/src/program/error.rs
@@ -4,11 +4,22 @@ use thiserror::Error;
/// Error type returned when a panic occurs during execution.
#[derive(Error)]
-#[error("execution panicked: {payload:?}")]
pub struct ProgramPanic {
pub payload: Box<dyn Any + Send>,
}
+impl fmt::Display for ProgramPanic {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ if let Some(s) = self.payload.downcast_ref::<&str>() {
+ write!(f, "{}", s)
+ } else if let Some(s) = self.payload.downcast_ref::<String>() {
+ write!(f, "{}", s)
+ } else {
+ write!(f, "")
+ }
+ }
+}
+
impl ProgramPanic {
pub fn new(payload: Box<dyn Any + Send>) -> Self {
ProgramPanic { payload }