pak_db/
error.rs

1use thiserror::Error;
2
3use crate::query::pql::PqlToken;
4
5pub type PakResult<T> = Result<T, PakError>;
6
7#[derive(Error, Debug)]
8pub enum PakError {
9    #[error("Type mismatch error: {0} found, {1} expected")]
10    TypeMismatchError(String, String),
11    #[error("Was unable to update rules item: {0}")]
12    UpdateRuleItemError(String),
13    #[error("Was unable to insert rules item: {0}")]
14    InsertRuleItemError(String),
15    #[error("There was an error packing the module: {0}")]
16    BincodeError(#[from] Box<bincode::ErrorKind>),
17    #[error("There was an error packing the module: {0}")]
18    FileError(#[from] std::io::Error),
19    #[error("PQL Error")]
20    PqlError(#[from] PqlError),
21    #[error("Unable to find index `{0}` in Pak. Make sure that this index is correctly spelled.")]
22    InvalidIndex(String)
23}
24
25pub type PqlResult<T> = Result<T, PqlError>;
26
27#[derive(Error, Debug)]
28pub enum PqlError {
29    #[error("Reached end of file unexpectedly at the end of a group.")]
30    EndOfFile,
31    #[error("")]
32    NoMatch,
33    #[error("Unexpected Token: Got `{0:?}` while expecting '{1}`.")]
34    UnexpectedToken(PqlToken, String)
35}
36
37impl PqlError {
38    pub fn is_no_match(&self) -> bool {
39        matches!(self, PqlError::NoMatch)
40    }
41}