Skip to main content

rover/storage/
error.rs

1//! Storage-layer error type.
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum StorageError {
7    #[error("failed to open database at {path}: {source}")]
8    Open {
9        path: String,
10        #[source]
11        source: tokio_rusqlite::Error,
12    },
13
14    #[error("failed to apply migration {name}: {source}")]
15    Migration {
16        name: String,
17        #[source]
18        source: tokio_rusqlite::Error,
19    },
20
21    #[error("database error: {0}")]
22    Backend(#[from] tokio_rusqlite::Error),
23}
24
25impl From<rusqlite::Error> for StorageError {
26    fn from(err: rusqlite::Error) -> Self {
27        Self::Backend(tokio_rusqlite::Error::Error(err))
28    }
29}