Files
fluid/backend-rust/step2-database-only/src/errors.rs

19 lines
363 B
Rust
Raw Normal View History

2019-08-14 23:22:15 +03:00
use std::fmt;
2019-08-14 22:15:38 +03:00
2019-08-14 23:22:15 +03:00
#[derive(Debug)]
pub struct Error(String);
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
pub fn err_msg(s: &str) -> Box<Error> {
2019-08-14 22:15:38 +03:00
Error(s.to_string()).into()
}
2019-08-16 17:24:18 +03:00
pub type AppResult<T> = ::std::result::Result<T, Box<Error>>;