1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Error, Debug, Clone, PartialEq)]
10pub enum Error {
11 #[error("Invalid field type: {field_type}")]
13 InvalidFieldType { field_type: String },
14
15 #[error("Invalid header format: {reason}")]
17 InvalidHeader { reason: String },
18
19 #[error("Invalid sequence number: {line}")]
21 InvalidSequenceNumber { line: String },
22
23 #[error("Schema mismatch: expected {expected} fields, got {actual}")]
25 SchemaMismatch { expected: usize, actual: usize },
26
27 #[error("Invalid value for field '{field}' of type {field_type}: {value}")]
29 InvalidValue {
30 field: String,
31 field_type: String,
32 value: String,
33 },
34
35 #[error("Missing header line")]
37 MissingHeader,
38
39 #[error("Document is empty")]
41 EmptyDocument,
42
43 #[error("Field '{field}' not found in schema")]
45 FieldNotFound { field: String },
46
47 #[error("Duplicate field name: {field}")]
49 DuplicateField { field: String },
50
51 #[error("Row {row_index} validation failed: {reason}")]
53 RowValidation { row_index: usize, reason: String },
54
55 #[error("Invalid hex value: {value}")]
57 InvalidHex { value: String },
58
59 #[error("Invalid number: {value}")]
61 InvalidNumber { value: String },
62
63 #[error("IO error: {0}")]
65 Io(String),
66}