gonzalo_core/error.rs
1//! Core error type. Note: write *conflicts* are NOT errors — they are a
2//! typed `PutResult` variant (see `store.rs`). Errors here are genuine
3//! failures (I/O, serialization, missing parent for an update).
4
5use crate::RecordKey;
6use thiserror::Error;
7
8#[derive(Debug, Error)]
9pub enum CoreError {
10 #[error("record not found: {0}")]
11 NotFound(RecordKey),
12 #[error("serialization error: {0}")]
13 Serde(String),
14 /// The call itself is wrong, and repeating it unchanged cannot succeed: a
15 /// consumer `put` of a tombstone record, for instance, which must go
16 /// through `delete_as`. Kept apart from [`Backend`](Self::Backend) so a
17 /// caller — and the daemon, which answers `400`/`InvalidArgument` rather
18 /// than `500` — can tell "you asked for something impossible" from "the
19 /// store failed" (gonzalo#299).
20 #[error("invalid request: {0}")]
21 Invalid(String),
22 #[error("backend error: {0}")]
23 Backend(String),
24}
25
26pub type Result<T> = std::result::Result<T, CoreError>;