Skip to main content

talea_core/api/
error.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Deserialize, Serialize)]
4#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
5#[serde(tag = "error", rename_all = "snake_case")]
6pub enum ApiError {
7    Unbalanced {
8        asset: String,
9        debit: i64,
10        credit: i64,
11    },
12    AssetMismatch {
13        account: String,
14        account_asset: String,
15        asset: String,
16    },
17    InvalidAmount {
18        amount: i64,
19    },
20    UnknownAsset {
21        asset: String,
22    },
23    UnknownAccount {
24        account: String,
25    },
26    ConstraintViolation {
27        account: String,
28        min_balance: i64,
29        would_be: i64,
30    },
31    AlreadyExists {
32        what: String,
33    },
34    InvalidDraft {
35        field: String,
36        reason: String,
37    },
38    NotFound {
39        what: String,
40    },
41    /// Client-side transport failure (network error, retry budget exhausted,
42    /// undecodable response). Never produced by the server.
43    Transport {
44        message: String,
45    },
46    Unauthorized,
47    /// The token is valid but its scope does not cover this book/operation.
48    /// For the global asset registry the book field carries "*".
49    Forbidden {
50        book: String,
51    },
52    /// The per-book write queue is full. Retry with the same idempotency
53    /// key — overload degrades to "retry later", never "maybe applied twice".
54    Overloaded,
55    /// The request exceeded the server's processing deadline. Safe to retry
56    /// with the same idempotency key.
57    Timeout,
58    Internal {
59        message: String,
60    },
61}