1#[derive(Debug)]
2pub enum Error {
3 Build(String),
4 Param(String),
5 #[cfg(feature = "d1")]
6 D1(worker::Error),
7 #[cfg(feature = "sqlite")]
8 Sqlite(rusqlite::Error),
9 Other(String),
10}
11
12impl std::fmt::Display for Error {
13 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14 match self {
15 Error::Build(msg) => write!(f, "Build Error: {}", msg),
16 Error::Param(msg) => write!(f, "Parameter Error: {}", msg),
17 #[cfg(feature = "d1")]
18 Error::D1(e) => write!(f, "D1 Error: {}", e),
19 #[cfg(feature = "sqlite")]
20 Error::Sqlite(e) => write!(f, "Sqlite Error: {}", e),
21 Error::Other(msg) => write!(f, "Other Error: {}", msg),
22 }
23 }
24}
25
26impl std::error::Error for Error {}
27
28#[cfg(feature = "d1")]
29impl From<worker::Error> for Error {
30 fn from(e: worker::Error) -> Self {
31 Error::D1(e)
32 }
33}
34
35#[cfg(feature = "sqlite")]
36impl From<rusqlite::Error> for Error {
37 fn from(e: rusqlite::Error) -> Self {
38 Error::Sqlite(e)
39 }
40}