aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program/error.rs
blob: 5e92a4271dd327635cd65332b300507c17aa4033 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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<dyn Any + Send>,
}

impl ProgramPanic {
    pub fn new(payload: Box<dyn Any + Send>) -> Self {
        ProgramPanic { payload }
    }
}

impl fmt::Debug for ProgramPanic {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{:?}", self.payload)
    }
}