#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub enum ErrorPolicy {
Skip,
#[default]
Fail,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum ErrorClass {
Retryable,
RecordLevel,
Fatal,
}
#[derive(Debug, thiserror::Error)]
#[error("fatal error in {component}: {reason}")]
pub struct FatalError {
pub component: String,
pub reason: String,
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum DeserError {
#[error("malformed payload: {reason}")]
Malformed {
reason: String,
},
#[error("schema unavailable: {reason}")]
SchemaUnavailable {
reason: String,
},
#[error("not ready: {reason}")]
NotReady {
reason: String,
},
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum SourceError {
#[error("source error ({class:?}): {reason}")]
Client {
class: ErrorClass,
reason: String,
},
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum SinkError {
#[error("sink error ({class:?}): {reason}")]
Client {
class: ErrorClass,
reason: String,
},
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn defaults_match_documented_policy() {
assert_eq!(ErrorPolicy::default(), ErrorPolicy::Fail);
}
#[test]
fn errors_render_reasons() {
let e = DeserError::Malformed {
reason: "truncated header".into(),
};
assert!(e.to_string().contains("truncated header"));
}
}