rustbasic_core/sql/
error.rs1use std::fmt;
2
3#[derive(Debug)]
4pub enum Error {
5 Database(String),
6 RowNotFound,
7 ColumnNotFound(String),
8 ColumnIndexOutOfBounds { len: usize, index: usize },
9 DecodeError(String),
10 Protocol(String),
11}
12
13impl std::error::Error for Error {}
14
15impl fmt::Display for Error {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 Error::Database(msg) => write!(f, "Database error: {}", msg),
19 Error::RowNotFound => write!(f, "Row not found"),
20 Error::ColumnNotFound(col) => write!(f, "Column not found: {}", col),
21 Error::ColumnIndexOutOfBounds { len, index } => {
22 write!(f, "Column index out of bounds: len {}, index {}", len, index)
23 }
24 Error::DecodeError(msg) => write!(f, "Decode error: {}", msg),
25 Error::Protocol(msg) => write!(f, "Protocol error: {}", msg),
26 }
27 }
28}