1#![cfg(feature = "alloc")]
2
3use alloc::boxed::Box;
4use core::fmt::{self, Display};
5
6#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
8#[derive(Debug)]
9pub struct Exception {
10 pub(crate) what: Box<str>,
11}
12
13impl Display for Exception {
14 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15 f.write_str(&self.what)
16 }
17}
18
19#[cfg(feature = "std")]
20#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
21impl std::error::Error for Exception {}
22
23impl Exception {
24 #[allow(missing_docs)]
25 pub fn what(&self) -> &str {
26 &self.what
27 }
28}