sources_core/error.rs
1use thiserror::Error;
2
3/// Result alias for source operations.
4pub type Result<T> = std::result::Result<T, SourceError>;
5
6/// Why a [`ChangeCapture`](crate::cdc::ChangeCapture) failed to start or to
7/// produce the next change.
8///
9/// The split that matters to the engine is transient vs. fatal:
10/// [`Connection`](Self::Connection) is worth retrying (resume picks up from the
11/// last confirmed point), while [`Setup`](Self::Setup) needs operator
12/// intervention.
13#[derive(Debug, Error)]
14#[non_exhaustive]
15pub enum SourceError {
16 /// The connection to Postgres dropped or could not be established.
17 /// Transient: the engine may retry, and the mechanism resumes from its last
18 /// confirmed point.
19 #[error("connection failed: {0}")]
20 Connection(String),
21
22 /// Setup the mechanism depends on is missing or invalid — a dropped
23 /// replication slot, a missing publication, `wal_level` too low, missing
24 /// privileges. Not recoverable by retrying.
25 #[error("setup error: {0}")]
26 Setup(String),
27
28 /// A raw change could not be decoded into a [`Change`](crate::cdc::Change).
29 #[error("decode error: {0}")]
30 Decode(String),
31
32 /// A query against the source failed (assembling or resolving a document).
33 #[error("query error: {0}")]
34 Query(String),
35
36 /// The configuration uses a feature the active source implementation does
37 /// not support yet.
38 #[error("unsupported: {0}")]
39 Unsupported(String),
40}