utiles/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use thiserror::Error;

#[derive(Error, Debug)]
pub enum UtilesCopyError {
    #[error("src and dst: {0}")]
    SrcDstSame(String),

    #[error("src does not exist: {0}")]
    SrcNotExists(String),

    #[error("Conflict: {0}")]
    Conflict(String),
}

#[derive(Error, Debug)]
pub enum UtilesError {
    #[error("utiles error: {0}")]
    AdHoc(String),

    /// Error for unimplemented feature(s) with a string message for context
    #[error("Unimplemented: {0}")]
    Unimplemented(String),

    /// unsupported err for when a feature is not supported
    #[error("Unsupported: {0}")]
    Unsupported(String),

    #[error("Unknown filetype: {0}")]
    UnknownFiletype(String),

    #[error("invalid fspath: {0}")]
    InvalidFspath(String),

    #[error("No fspath extension: {0}")]
    NoFspathExtension(String),

    #[error("No fspath stem: {0}")]
    NoFspathStem(String),

    #[error("File does not exist: {0}")]
    FileDoesNotExist(String),

    #[error("metadata error: {0}")]
    MetadataError(String),

    #[error("Path already exists: {0}")]
    PathExistsError(String),

    #[error("Not a file: {0}")]
    NotAFile(String),

    #[error("Non mbtiles sqlite db: {0}")]
    NonMbtilesSqliteDb(String),

    #[error("parse int error: {0}")]
    ParseIntError(#[from] std::num::ParseIntError),

    #[error("parsing error: {0}")]
    ParsingError(String),

    #[error("Not mbtiles-like: {0}")]
    NotMbtilesLike(String),

    #[error("utiles error: {0}")]
    Error(String),

    #[error("unknown utiles error: {0}")]
    Unknown(String),

    #[error("path conversion error: {0}")]
    PathConversionError(String),

    /// simple string lock error type that might be good to fix up
    #[error("Lock error: {0}")]
    LockError(String),

    // ===============================================================
    // EXTERNAL ~ EXTERNAL ~ EXTERNAL ~ EXTERNAL ~ EXTERNAL ~ EXTERNAL
    // ===============================================================
    /// Error from the utiles-core crate
    #[error("utiles-core error: {0}")]
    CoreError(#[from] utiles_core::UtilesCoreError),

    /// Error from `utiles::copy`
    #[error("utiles-copy error: {0}")]
    CopyError(#[from] UtilesCopyError),

    /// Error from `serde_json`
    #[error("serde error: {0}")]
    SerdeJsonError(#[from] serde_json::Error),

    /// Error from `std::io`
    #[error("io error: {0}")]
    IoError(#[from] std::io::Error),

    /// Error from `sqlite` module
    #[error("{0}")]
    SqliteError(#[from] crate::sqlite::SqliteError),

    /// Error from rusqlite
    #[error("rusqlite err: {0}")]
    RusqliteError(#[from] rusqlite::Error),

    /// Error from `async_sqlite`
    #[error("sqlite err: {0}")]
    AsyncSqliteError(#[from] async_sqlite::Error),

    /// Geojson error(s)
    #[error("geojson error: {0}")]
    GeojsonError(String),

    /// Error from globset
    #[error("globset error: {0}")]
    GlobsetError(#[from] globset::Error),

    /// Image error
    #[error("image error: {0}")]
    ImageError(#[from] image::ImageError),

    /// Error from `json_patch`
    #[error("json_patch error: {0}")]
    JsonPatchError(#[from] json_patch::PatchError),

    /// Error from `tokio::task`
    #[error("tokio::task::JoinError - {0}")]
    TokioJoinError(#[from] tokio::task::JoinError),

    /// Error from `pmtiles`
    #[cfg(feature = "pmtiles")]
    #[error("pmtiles error: {0}")]
    PmtilesError(#[from] pmtiles::PmtError),
    // /// Error from `oxipng`
    // #[error("oxipng::PngError: {0}")]
    // OxipngError(#[from] oxipng::PngError),

    // /// ndarray shape error
    // #[error("ndarray shape error: {0}")]
    // NdarrayShapeError(#[from] ndarray::ShapeError),
}

pub type UtilesResult<T, E = UtilesError> = Result<T, E>;