use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("payload too large: {size} bytes, maximum is {max}")]
PayloadTooLarge {
size: usize,
max: usize,
},
#[error("application outbox is full; the cover rate is too low for the current publish rate")]
AppOutboxFull,
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}
impl From<peashape::Error> for Error {
fn from(e: peashape::Error) -> Self {
match e {
peashape::Error::PayloadTooLarge { size, max } => Error::PayloadTooLarge { size, max },
peashape::Error::LaneFull => Error::AppOutboxFull,
peashape::Error::Io(io) => Error::Io(io),
other => Error::Io(std::io::Error::other(other.to_string())),
}
}
}