sqlite_fsr/models/
error.rs

1use std::io::{self};
2
3#[derive(Debug, thiserror::Error)]
4pub enum CommandArgsError {
5    #[error("Missing <database path> and <command>")]
6    MissingArgs,
7    #[error("Missing <command>")]
8    MissingCommand,
9    #[error("Missing or invalid command passed: {0}")]
10    InvalidCommand(String),
11    #[error("I/O error: {0}")]
12    Io(#[from] io::Error), // automatically adds From<io::Error>
13}
14
15#[derive(Debug, thiserror::Error)]
16pub enum SQLCommandError {
17    #[error("No table named \"{0}\" found")]
18    UnknownTable(String),
19    
20    #[error("SQL Command: \"{0}\" is not supported.")]
21    UnsupportedCommand(String)
22}
23
24
25#[derive(Debug, thiserror::Error)]
26pub enum SQLSyntaxError {
27    #[error("SQL Syntax Error: Unexpected token \"{0}\".")]
28    UnexpectedToken(String),
29    
30    #[error("SQL Syntax Error: Value is unsupported \"{0}\".")]
31    UnsupportedValue(String)
32
33}
34
35#[derive(Debug, thiserror::Error)]
36pub enum RunError {
37    #[error(transparent)]
38    Args(#[from] CommandArgsError),
39
40    #[error(transparent)]
41    Sql(#[from] SQLCommandError),
42}
43