#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum StoreError {
#[error("commit refused: {0}")]
Commit(#[from] openehr::rm::common::CommitError),
#[error("no such {kind}: {id}")]
NotFound {
kind: &'static str,
id: String,
},
#[error("{kind} already exists: {id}")]
Conflict {
kind: &'static str,
id: String,
},
#[error("{0}")]
Invalid(#[from] openehr::ValidationReport),
#[error(transparent)]
Parse(#[from] openehr::ParseError),
#[error("canonical JSON: {0}")]
Json(#[from] serde_json::Error),
#[error("{engine}: {message}")]
Engine {
engine: &'static str,
message: String,
},
#[error(
"database is at schema version {found}, this build writes {expected}; \
there is no migration path (see spec/databases/10-operations.md O10.14)"
)]
SchemaVersionMismatch {
found: i64,
expected: i64,
},
#[error("unsupported by {engine}: {what} (see {spec_ref})")]
Unsupported {
engine: &'static str,
what: &'static str,
spec_ref: &'static str,
},
}
pub type Result<T, E = StoreError> = core::result::Result<T, E>;