blob: 125e4843ef1270ad1f3061eb9ecab377bbc097fd [file] [log] [blame]
David Tolnayebef4a22020-03-17 15:33:47 -07001use std::fmt::{self, Debug, Display};
David Tolnayebef4a22020-03-17 15:33:47 -07002
3/// Exception thrown from an `extern "C"` function.
David Tolnayeedf7372020-05-22 11:08:50 -07004#[derive(Debug)]
David Tolnayebef4a22020-03-17 15:33:47 -07005pub struct Exception {
6 pub(crate) what: Box<str>,
7}
8
9impl Display for Exception {
10 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11 f.write_str(&self.what)
12 }
13}
14
15impl std::error::Error for Exception {}
16
17impl Exception {
18 pub fn what(&self) -> &str {
19 &self.what
20 }
21}