Skip to content
Snippets Groups Projects
error.rs 957 B
Newer Older
Stephen D's avatar
Stephen D committed
use snafu::prelude::*;

#[derive(Debug, Snafu)]
pub enum DecodeError {
    #[snafu(display("Unexpected end of input"))]
    UnexpectedEndOfInput,

    #[snafu(display("Malformed whisker at position `{}`", position))]
    MalformedWhisker { position: usize },

    #[snafu(display("Duplicate whisker at position `{}`", position))]
    DuplicateWhisker { position: usize },
Stephen D's avatar
Stephen D committed
    #[snafu(display("Comment data is not valid UTF-8"))]
    InvalidComment,

    #[snafu(display("CRC checksum mismatch"))]
    CrcMismatch,
}

#[derive(Debug, Snafu)]
pub enum EncodeError {
    #[snafu(display("New data is a duplicate of an existing data"))]
    DuplicateData,

    #[snafu(display("Given data causes CATS packet to overflow"))]
    CatsOverflow,
Stephen D's avatar
Stephen D committed
}

#[derive(Debug, Snafu)]
pub enum CommentError {
    #[snafu(display("CATS packet does not have comment data"))]
    NoComment,

    #[snafu(display("Given buffer too small for comment data"))]
    BufferOverflow,
}