1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum TypeError {
8 #[error("unexpected null value")]
10 UnexpectedNull,
11
12 #[error("type mismatch: expected {expected}, got {actual}")]
14 TypeMismatch {
15 expected: &'static str,
17 actual: String,
19 },
20
21 #[error("value out of range for {target_type}")]
23 OutOfRange {
24 target_type: &'static str,
26 },
27
28 #[error("invalid string encoding: {0}")]
30 InvalidEncoding(String),
31
32 #[error("invalid binary data: {0}")]
34 InvalidBinary(String),
35
36 #[error("invalid date/time: {0}")]
38 InvalidDateTime(String),
39
40 #[error("invalid decimal: {0}")]
42 InvalidDecimal(String),
43
44 #[error("invalid UUID: {0}")]
46 InvalidUuid(String),
47
48 #[error("value truncated: {0}")]
50 Truncation(String),
51
52 #[error("unsupported conversion from {from} to {to}")]
54 UnsupportedConversion {
55 from: String,
57 to: &'static str,
59 },
60
61 #[error("buffer too small: need {needed} bytes, have {available}")]
63 BufferTooSmall {
64 needed: usize,
66 available: usize,
68 },
69}