1use std::fmt;
2pub use std::io::Error as IoError;
3pub use std::io::ErrorKind;
4
5pub type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
6
7pub type Result<T> = std::result::Result<T, Error>;
8
9pub fn to_io_error(e: Error) -> IoError {
10 return IoError::new(ErrorKind::Other, e);
11}
12
13#[derive(Debug)]
14pub struct BasinError {
15 message: String,
16}
17
18impl BasinError {
19 pub fn new(message: String) -> BasinError {
20 BasinError { message }
21 }
22}
23
24impl fmt::Display for BasinError {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 write!(f, "BasinError {{ {} }}", self.message)
27 }
28}
29
30impl std::error::Error for BasinError {}
31
32#[macro_export]
33macro_rules! basin_err {
34 ($($arg:tt)*) => { Box::new(BasinError::new(format!($($arg)*))) }
35}