| 1 | //! Crate-wide error type. |
| 2 | |
| 3 | /// Errors produced by the core domain and storage layers. |
| 4 | #[derive(Debug, thiserror::Error)] |
| 5 | pub enum Error { |
| 6 | #[error("database error: {0}")] |
| 7 | Db(#[from] toasty::Error), |
| 8 | |
| 9 | #[error("repository storage error: {0}")] |
| 10 | Storage(String), |
| 11 | |
| 12 | #[error("password hashing error: {0}")] |
| 13 | Password(String), |
| 14 | |
| 15 | #[error("config error: {0}")] |
| 16 | Config(String), |
| 17 | |
| 18 | #[error("not found: {0}")] |
| 19 | NotFound(String), |
| 20 | |
| 21 | #[error("already exists: {0}")] |
| 22 | AlreadyExists(String), |
| 23 | |
| 24 | #[error("invalid input: {0}")] |
| 25 | Invalid(String), |
| 26 | |
| 27 | #[error(transparent)] |
| 28 | Io(#[from] std::io::Error), |
| 29 | |
| 30 | #[error("JSON error: {0}")] |
| 31 | Json(#[from] serde_json::Error), |
| 32 | } |
| 33 | |
| 34 | /// Convenience alias used throughout the crate. |
| 35 | pub type Result<T> = std::result::Result<T, Error>; |