imessage_database/error/
table.rs

1/*!
2 Errors that can happen when extracting data from a `SQLite` table.
3*/
4
5use std::fmt::{Display, Formatter, Result};
6
7/// Errors that can happen when extracting data from a `SQLite` table
8#[derive(Debug)]
9pub enum TableError {
10    Attachment(rusqlite::Error),
11    ChatToHandle(rusqlite::Error),
12    Chat(rusqlite::Error),
13    Handle(rusqlite::Error),
14    Messages(rusqlite::Error),
15    CannotConnect(String),
16    CannotRead(std::io::Error),
17}
18
19impl Display for TableError {
20    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
21        match self {
22            TableError::Attachment(why) => write!(fmt, "Failed to parse attachment row: {why}"),
23            TableError::ChatToHandle(why) => write!(fmt, "Failed to parse chat handle row: {why}"),
24            TableError::Chat(why) => write!(fmt, "Failed to parse chat row: {why}"),
25            TableError::Handle(why) => write!(fmt, "Failed to parse handle row: {why}"),
26            TableError::Messages(why) => write!(fmt, "Failed to parse messages row: {why}"),
27            TableError::CannotConnect(why) => write!(fmt, "{why}"),
28            TableError::CannotRead(why) => write!(fmt, "{why}"),
29        }
30    }
31}