1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*!
 Errors that can happen when extracting data from a SQLite table
*/

use std::fmt::{Display, Formatter, Result};

use rusqlite::Error;

#[derive(Debug)]
pub enum TableError {
    Attachment(Error),
    ChatToHandle(Error),
    Chat(Error),
    Handle(Error),
    Messages(Error),
}

impl Display for TableError {
    fn fmt(&self, fmt: &mut Formatter<'_>) -> Result {
        match self {
            TableError::Attachment(why) => write!(fmt, "Failed to parse row: {why}"),
            TableError::ChatToHandle(why) => write!(fmt, "Failed to parse row: {why}"),
            TableError::Chat(why) => write!(fmt, "Failed to parse row: {why}"),
            TableError::Handle(why) => write!(fmt, "Failed to parse row: {why}"),
            TableError::Messages(why) => write!(fmt, "Failed to parse row: {why}"),
        }
    }
}