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 InvalidMaxRows(i32),
20 UnsupportedAction(Action),
22 UnsafeExpression(String),
24}
25
26impl fmt::Display for EncodeError {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 EncodeError::NullByte => {
30 write!(
31 f,
32 "Value contains NULL byte (0x00) which is invalid in PostgreSQL"
33 )
34 }
35 EncodeError::TooManyParameters(count) => {
36 write!(f, "Too many parameters: {} (Limit is 32767)", count)
37 }
38 EncodeError::MessageTooLarge(size) => {
39 write!(
40 f,
41 "Message too large: {} bytes (Limit is {})",
42 size,
43 i32::MAX
44 )
45 }
46 EncodeError::InvalidMaxRows(v) => {
47 write!(f, "Invalid Execute max_rows: {} (must be >= 0)", v)
48 }
49 EncodeError::UnsupportedAction(action) => {
50 write!(f, "Unsupported action {:?} in AST-native encoder", action)
51 }
52 EncodeError::UnsafeExpression(expr) => {
53 write!(f, "Unsafe expression rejected: {}", expr)
54 }
55 }
56 }
57}
58
59impl std::error::Error for EncodeError {}