vms2_tile_db_reader/error/
mod.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum Error {
5    DbError {
6        message: String,
7        source: Option<Box<dyn std::error::Error + 'static>>,
8    },
9}
10
11impl fmt::Display for Error {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        match self {
14            Error::DbError { message, .. } => write!(f, "Database error: {}", message),
15        }
16    }
17}
18
19impl std::error::Error for Error {
20    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
21        match self {
22            Error::DbError {
23                source: Some(err), ..
24            } => Some(&**err),
25            _ => None,
26        }
27    }
28}