wackasm_opencomputers/
error.rs1use std::fmt;
2
3#[derive(Clone, Debug, PartialEq)]
5pub enum Error {
6 NoSuchComponent,
8 NoSuchMethod,
10 Failed(String),
13 UnexpectedReply(String),
15 ProgramNotFound(String),
17}
18
19impl fmt::Display for Error {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Error::NoSuchComponent => f.write_str("no such component"),
23 Error::NoSuchMethod => f.write_str("no such method"),
24 Error::Failed(reason) => f.write_str(reason),
25 Error::UnexpectedReply(what) => write!(f, "unexpected reply: {what}"),
26 Error::ProgramNotFound(name) => write!(f, "{name}: command not found"),
27 }
28 }
29}
30
31impl std::error::Error for Error {}
32
33pub type Result<T> = std::result::Result<T, Error>;