24 lines
450 B
Rust
24 lines
450 B
Rust
use std::fmt::{Display, Formatter};
|
|
|
|
#[derive(Debug)]
|
|
pub struct Error {
|
|
message: String,
|
|
}
|
|
|
|
impl Error {
|
|
pub fn new(message: impl AsRef<str>) -> Self {
|
|
Self {
|
|
message: message.as_ref().to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
f.write_fmt(format_args!("{}", self.message))?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for Error {}
|