blob: 46eedd6d399a7518a3c3e68e9404da6eab5953e4 (
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
31
32
33
34
35
36
37
38
39
|
use std::error::Error;
#[derive(Debug)]
pub enum WebhoggException {
DomError(String),
WebGlContextError(String),
}
impl WebhoggException {
fn err_name(&self) -> &str {
match self {
WebhoggException::DomError(_) => "DomError",
WebhoggException::WebGlContextError(_) => "WebGlContextError",
}
}
}
impl Error for WebhoggException {
fn description(&self) -> &str {
match self {
WebhoggException::DomError(desc) => desc,
WebhoggException::WebGlContextError(desc) => desc,
}
}
fn cause(&self) -> Option<&dyn Error> {
self.source()
}
fn source(&self) -> Option<&(dyn Error + 'static)> {
None
}
}
impl std::fmt::Display for WebhoggException {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "WebhoggException::{} {}", self.err_name(), self.description())
}
}
|