blob: b54411294086dbe8029c14c9171e2c584ea61f0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use std::error::Error;
#[derive(Debug)]
pub enum WasmError {
TestError(String),
}
impl std::fmt::Display for WasmError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(f, "{}: {}", self.name(), self.description())
}
}
impl Error for WasmError {
fn description(&self) -> &str {
match self {
WasmError::TestError(msg) => msg,
}
}
fn source(&self) -> Option<&'static dyn Error> { None }
}
impl WasmError {
pub fn name(&self) -> &str {
match self {
WasmError::TestError(_) => "TestError",
}
}
}
|