1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! [`ConversionError`]: shared failure mode for digesting a CDC wire
//! event (`pg_walstream`, `wal2json`, `maxwell`) into a diff builder.
//!
//! The three forward sources previously each defined a near-identical
//! copy of this enum. They now share this one type and re-export it, so
//! the shared build helpers in [`shared_builders`](super::shared_builders)
//! return a single error type across every source.
use alloc::string::String;
use super::error::DecodeError;
/// Errors raised while folding a CDC wire event into a diff builder.
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum ConversionError {
/// A column name from the event was not found in the table schema.
#[error("Column '{0}' not found in table schema")]
ColumnNotFound(String),
/// The table name in the event does not match the expected schema.
#[error("Table name mismatch: expected '{expected}', got '{actual}'")]
TableMismatch {
/// Expected table name from the schema.
expected: String,
/// Actual table name from the wire event.
actual: String,
},
/// Table named in the wire event is not in the schema.
#[error("Table '{0}' not found in schema")]
TableNotFound(String),
/// The event is missing a required set of columns (for example the
/// full column list, or every primary-key column of a delete).
#[error("Missing columns in event")]
MissingColumns,
/// The event is missing required data for an operation. The tuple is
/// (what was missing, operation name), for example `("pk", "DELETE")`.
#[error("Missing {0} data for {1} operation")]
MissingData(&'static str, &'static str),
/// Old-row data is required but not available (replica identity issue).
#[error("Old data not available (check replica identity setting)")]
MissingOldData,
/// A JSON value type is not supported for conversion.
#[error("Unsupported value type for column '{0}'")]
UnsupportedType(String),
/// The event type is not applicable for the requested conversion.
#[error("Event type '{0}' cannot be converted to the requested operation")]
InvalidEventType(String),
/// The operation type is not applicable for the requested conversion.
#[error("Operation '{0}' cannot be converted to the requested type")]
InvalidOperation(String),
/// A user-registered decoder rejected a column payload.
#[error("Decoder failed: {0}")]
Decode(#[from] DecodeError),
}