Skip to main content

maxwell_cdc/
error.rs

1//! What a failed parse reports.
2
3use alloc::string::String;
4use thiserror::Error;
5
6/// Why a Maxwell message failed to parse.
7#[derive(Debug, Error)]
8pub enum ParseError {
9    /// The message carries a `type` this crate does not model, most likely because it was
10    /// added by a newer Maxwell. Callers tailing a stream may choose to skip these.
11    #[error("unrecognised Maxwell message type `{0}`")]
12    UnknownMessageType(String),
13    /// The input is not valid JSON, or is not a valid message of its declared type.
14    #[error(transparent)]
15    Json(#[from] serde_json::Error),
16}
17
18/// A parse failure at a known line of a JSON Lines stream.
19#[derive(Debug, Error)]
20#[error("line {line}: {source}")]
21pub struct LineError {
22    /// Line number, counting from one.
23    pub line: usize,
24    /// The underlying failure.
25    #[source]
26    pub source: ParseError,
27}