Skip to main content

kcode_server_object_envelopes/
error.rs

1use std::fmt;
2
3/// A rejected envelope input or invalid stored payload.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct Error {
6    message: String,
7}
8
9/// Result type for envelope operations.
10pub type Result<T> = std::result::Result<T, Error>;
11
12impl Error {
13    pub(crate) fn new(message: impl Into<String>) -> Self {
14        Self {
15            message: message.into(),
16        }
17    }
18}
19
20impl fmt::Display for Error {
21    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
22        formatter.write_str(&self.message)
23    }
24}
25
26impl std::error::Error for Error {}