wasmflow_packet/
error.rs

1/// The error type used when attempting to deserialize a [crate::Packet].
2#[derive(Debug)]
3pub enum Error {
4  /// Tried to deserialize a Signal packet.
5  Signal,
6  /// Invalid payload.
7  Invalid,
8  /// Packet was an Exception.
9  Exception(String),
10  /// Packet was an Error.
11  Error(String),
12  /// An error deserializing from MessagePack.
13  DeserializationError(wasmflow_codec::Error),
14  /// An Internal error given when the packet contained a message not destined for a consumer.
15  InternalError,
16}
17
18impl std::fmt::Display for Error {
19  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20    match self {
21      Error::Signal => write!(f, "Tried to deserialize a Signal packet"),
22      Error::Invalid => write!(f, "Refused to deserialize invalid payload"),
23      Error::Exception(v) => write!(f, "Exception: {}", v),
24      Error::Error(v) => write!(f, "Error: {}", v),
25      Error::DeserializationError(e) => {
26        write!(f, "Deserialization Error: {}", e)
27      }
28      Error::InternalError => write!(f, "Internal Deserialization Error"),
29    }
30  }
31}
32
33impl std::error::Error for Error {}