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