1use wasmflow_transport::error::TransportError;
2
3#[derive(Debug)]
5pub enum Error {
6 Codec(String),
8
9 EndOfOutput(String),
11
12 PortNotFound(String),
14
15 Component(String),
17}
18
19impl From<TransportError> for Error {
20 fn from(e: TransportError) -> Self {
21 Error::Codec(e.to_string())
22 }
23}
24
25impl From<&str> for Error {
26 fn from(e: &str) -> Self {
27 Error::Component(e.to_owned())
28 }
29}
30
31impl From<String> for Error {
32 fn from(e: String) -> Self {
33 Error::Component(e)
34 }
35}
36
37impl std::fmt::Display for Error {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 match self {
40 Error::Codec(e) => write!(f, "Codec error: {}", e),
41 Error::Component(v) => write!(f, "{}", v),
42 Error::EndOfOutput(v) => write!(f, "No output available for port '{}'", v),
43 Error::PortNotFound(v) => write!(
44 f,
45 "Tried to take packet from port '{}' but port '{}' never received anything.",
46 v, v
47 ),
48 }
49 }
50}
51
52impl std::error::Error for Error {}