Files
rust-otus/smart-house/house/src/error.rs
2026-04-11 10:47:12 +03:00

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 {}