1#[derive(Debug, thiserror::Error)]
5pub enum ForceSyncError {
6 #[error("database pool error: {0}")]
8 Pool(#[from] deadpool_postgres::PoolError),
9
10 #[error("database error: {0}")]
12 Database(#[from] tokio_postgres::Error),
13
14 #[error("sync journal entries require a source cursor")]
16 MissingSourceCursor,
17
18 #[error(
20 "transaction callback failed and rollback also failed: callback={callback}; rollback={rollback}"
21 )]
22 TransactionRollback {
23 callback: Box<Self>,
25 rollback: tokio_postgres::Error,
27 },
28
29 #[error("sync key {part} cannot be empty")]
31 EmptySyncKeyPart {
32 part: &'static str,
34 },
35
36 #[error("missing {entity}")]
38 NotFound {
39 entity: &'static str,
41 },
42
43 #[error("missing required configuration: {field}")]
45 MissingConfiguration {
46 field: &'static str,
48 },
49
50 #[error("lease duration is out of range")]
52 InvalidLeaseDuration,
53
54 #[error("json error: {0}")]
56 Json(#[from] serde_json::Error),
57
58 #[error("pubsub error: {0}")]
60 PubSub(Box<force_pubsub::PubSubError>),
61
62 #[error("invalid outbox operation: {op}")]
64 InvalidOutboxOperation {
65 op: String,
67 },
68
69 #[error("invalid outbox cursor: {cursor}")]
71 InvalidOutboxCursor {
72 cursor: String,
74 },
75
76 #[error("invalid stored value for {field}: {value}")]
78 InvalidStoredValue {
79 field: &'static str,
81 value: String,
83 },
84
85 #[error("not implemented")]
87 NotImplemented,
88}
89
90impl From<force_pubsub::PubSubError> for ForceSyncError {
91 fn from(error: force_pubsub::PubSubError) -> Self {
92 Self::PubSub(Box::new(error))
93 }
94}