cxx/
exception.rs

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