#[allow(missing_copy_implementations)]
#[derive(Debug, Clone)]
pub enum Error {
OpList(String),
RSocket(u32),
ReceiverAlreadyGone,
WrongType,
StringConversion,
MetadataNotFound,
Frame(wasmrs_frames::Error),
Record(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::RSocket(code) => f.write_str((Into::<u32>::into(*code)).to_string().as_str()),
Error::OpList(msg) => f.write_str(msg),
Error::ReceiverAlreadyGone => f.write_str("Received already taken"),
Error::WrongType => f.write_str("Tried to decode frame with wrong frame decoder"),
Error::StringConversion => f.write_str("Could not read string bytes"),
Error::MetadataNotFound => f.write_str("No metadata found"),
Error::Frame(e) => f.write_str(e.to_string().as_str()),
Error::Record(e) => f.write_str(e.as_str()),
}
}
}
impl From<wasmrs_frames::Error> for Error {
fn from(value: wasmrs_frames::Error) -> Self {
Error::Frame(value)
}
}