35 lines
669 B
Rust
35 lines
669 B
Rust
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Error {
|
|
message: String,
|
|
}
|
|
|
|
impl std::fmt::Display for Error {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{}", &self.message)
|
|
}
|
|
}
|
|
|
|
impl Error {
|
|
pub fn new(message: &str) -> Self {
|
|
Error {
|
|
message: message.to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<T: std::error::Error> From<T> for Error {
|
|
fn from(source: T) -> Self {
|
|
Self {
|
|
message: source.to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<Error> for emacs::Error {
|
|
fn from(source: Error) -> Self {
|
|
emacs::Error::msg(source)
|
|
}
|
|
}
|