aboutsummaryrefslogtreecommitdiff
path: root/src/exception.rs
blob: f61e8fa95b79067e24a78417f0a32665322ddd97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use alloc::boxed::Box;
use core::fmt::{self, Debug, Display};

/// Exception thrown from an `extern "C++"` function.
#[derive(Debug)]
pub struct Exception {
    pub(crate) what: Box<str>,
}

impl Display for Exception {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str(&self.what)
    }
}

impl std::error::Error for Exception {}

impl Exception {
    pub fn what(&self) -> &str {
        &self.what
    }
}