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
#[allow(missing_copy_implementations)]
#[derive(Debug, Clone)]
pub enum Error {
RecvFailed(u8),
ReceiverAlreadyGone,
Runtime(String),
Decode(String),
}
impl std::error::Error for Error {}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::RecvFailed(_) => f.write_str("Receive failed"),
Error::ReceiverAlreadyGone => f.write_str("Received already taken"),
Error::Decode(e) => {
let mut message = "Decode error: ".to_owned();
message.push_str(e);
f.write_str(e)
}
Error::Runtime(msg) => f.write_str(msg),
}
}
}
impl From<wasmrs_runtime::Error> for Error {
fn from(e: wasmrs_runtime::Error) -> Self {
Self::Runtime(e.to_string())
}
}