Skip to main content

awa_model/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum AwaError {
5    #[error("job not found: {id}")]
6    JobNotFound { id: i64 },
7
8    #[error("unique conflict")]
9    UniqueConflict { existing_id: Option<String> },
10
11    #[error("schema not migrated: expected version {expected}, found {found}")]
12    SchemaNotMigrated { expected: i32, found: i32 },
13
14    #[error("unknown job kind: {kind}")]
15    UnknownJobKind { kind: String },
16
17    #[error("serialization error: {0}")]
18    Serialization(#[from] serde_json::Error),
19
20    #[error("database error: {0}")]
21    Database(#[source] sqlx::Error),
22}
23
24impl From<sqlx::Error> for AwaError {
25    fn from(err: sqlx::Error) -> Self {
26        AwaError::Database(err)
27    }
28}