1 use alloc::boxed::Box;
2 use core::fmt::{self, Debug, Display};
3 
4 /// Exception thrown from an `extern "C++"` function.
5 #[derive(Debug)]
6 pub struct Exception {
7     pub(crate) what: Box<str>,
8 }
9 
10 impl Display for Exception {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result11     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12         f.write_str(&self.what)
13     }
14 }
15 
16 impl std::error::Error for Exception {}
17 
18 impl Exception {
what(&self) -> &str19     pub fn what(&self) -> &str {
20         &self.what
21     }
22 }
23