-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherror.rs
More file actions
51 lines (43 loc) · 1.22 KB
/
error.rs
File metadata and controls
51 lines (43 loc) · 1.22 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
use core::fmt;
#[derive(Debug, Clone)]
pub enum WasmUtxoError {
StringError(String),
}
impl std::error::Error for WasmUtxoError {}
impl fmt::Display for WasmUtxoError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
WasmUtxoError::StringError(s) => write!(f, "{}", s),
}
}
}
impl From<&str> for WasmUtxoError {
fn from(s: &str) -> Self {
WasmUtxoError::StringError(s.to_string())
}
}
impl From<String> for WasmUtxoError {
fn from(s: String) -> Self {
WasmUtxoError::StringError(s)
}
}
impl From<miniscript::Error> for WasmUtxoError {
fn from(err: miniscript::Error) -> Self {
WasmUtxoError::StringError(err.to_string())
}
}
impl From<miniscript::descriptor::NonDefiniteKeyError> for WasmUtxoError {
fn from(err: miniscript::descriptor::NonDefiniteKeyError) -> Self {
WasmUtxoError::StringError(err.to_string())
}
}
impl WasmUtxoError {
pub fn new(s: &str) -> WasmUtxoError {
WasmUtxoError::StringError(s.to_string())
}
}
impl From<crate::address::AddressError> for WasmUtxoError {
fn from(err: crate::address::AddressError) -> Self {
WasmUtxoError::StringError(err.to_string())
}
}