qail_pg/protocol/
error.rs1use std::fmt;
6
7use qail_core::ast::Action;
8
9#[derive(Debug, Clone, PartialEq, Eq)]
11pub enum EncodeError {
12 NullByte,
14 TooManyParameters(usize),
16 MessageTooLarge(usize),
18 UnsupportedAction(Action),
20 UnsafeExpression(String),
22}
23
24impl fmt::Display for EncodeError {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 match self {
27 EncodeError::NullByte => {
28 write!(
29 f,
30 "Value contains NULL byte (0x00) which is invalid in PostgreSQL"
31 )
32 }
33 EncodeError::TooManyParameters(count) => {
34 write!(f, "Too many parameters: {} (Limit is 32767)", count)
35 }
36 EncodeError::MessageTooLarge(size) => {
37 write!(
38 f,
39 "Message too large: {} bytes (Limit is {})",
40 size,
41 i32::MAX
42 )
43 }
44 EncodeError::UnsupportedAction(action) => {
45 write!(f, "Unsupported action {:?} in AST-native encoder", action)
46 }
47 EncodeError::UnsafeExpression(expr) => {
48 write!(f, "Unsafe expression rejected: {}", expr)
49 }
50 }
51 }
52}
53
54impl std::error::Error for EncodeError {}