2020-10-16 12:40:25 +00:00
|
|
|
use crate::commands::CommandError;
|
|
|
|
use crate::config::ConfigError;
|
2020-10-24 13:08:23 +00:00
|
|
|
use crate::db::errors::DataError;
|
2020-09-28 21:35:05 +00:00
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum BotError {
|
2020-10-15 16:52:08 +00:00
|
|
|
#[error("configuration error: {0}")]
|
|
|
|
ConfigurationError(#[from] ConfigError),
|
|
|
|
|
2020-09-28 21:35:05 +00:00
|
|
|
/// Sync token couldn't be found.
|
|
|
|
#[error("the sync token could not be retrieved")]
|
|
|
|
SyncTokenRequired,
|
|
|
|
|
2020-10-15 16:52:08 +00:00
|
|
|
#[error("command error: {0}")]
|
|
|
|
CommandError(#[from] CommandError),
|
|
|
|
|
|
|
|
#[error("database error: {0}")]
|
|
|
|
DataError(#[from] DataError),
|
|
|
|
|
2020-10-03 20:31:42 +00:00
|
|
|
#[error("the message should not be processed because it failed validation")]
|
|
|
|
ShouldNotProcessError,
|
|
|
|
|
2020-09-28 21:35:05 +00:00
|
|
|
#[error("no cache directory found")]
|
|
|
|
NoCacheDirectoryError,
|
|
|
|
|
|
|
|
#[error("could not parse URL")]
|
|
|
|
UrlParseError(#[from] url::ParseError),
|
|
|
|
|
2021-01-29 22:35:07 +00:00
|
|
|
#[error("error in matrix state store: {0}")]
|
|
|
|
MatrixStateStoreError(#[from] matrix_sdk::StoreError),
|
|
|
|
|
2020-09-28 21:35:05 +00:00
|
|
|
#[error("uncategorized matrix SDK error")]
|
|
|
|
MatrixError(#[from] matrix_sdk::Error),
|
|
|
|
|
|
|
|
#[error("uncategorized matrix SDK base error")]
|
|
|
|
MatrixBaseError(#[from] matrix_sdk::BaseError),
|
|
|
|
|
|
|
|
#[error("future canceled")]
|
|
|
|
FutureCanceledError,
|
|
|
|
|
|
|
|
//de = deserialization
|
|
|
|
#[error("toml parsing error")]
|
|
|
|
TomlParsingError(#[from] toml::de::Error),
|
|
|
|
|
2020-10-15 16:52:08 +00:00
|
|
|
#[error("i/o error: {0}")]
|
2020-09-28 21:35:05 +00:00
|
|
|
IoError(#[from] std::io::Error),
|
2020-10-04 21:32:50 +00:00
|
|
|
|
2020-10-15 16:52:08 +00:00
|
|
|
#[error("dice parsing error: {0}")]
|
2020-10-31 13:52:46 +00:00
|
|
|
DiceParsingError(#[from] crate::parser::DiceParsingError),
|
|
|
|
|
|
|
|
#[error("command parsing error: {0}")]
|
|
|
|
CommandParsingError(#[from] crate::commands::parser::CommandParsingError),
|
2020-10-04 21:32:50 +00:00
|
|
|
|
2020-11-04 20:09:39 +00:00
|
|
|
#[error("dice rolling error: {0}")]
|
2020-10-16 22:02:25 +00:00
|
|
|
DiceRollingError(#[from] DiceRollingError),
|
2020-10-16 21:30:02 +00:00
|
|
|
|
2020-10-15 16:52:08 +00:00
|
|
|
#[error("variable parsing error: {0}")]
|
|
|
|
VariableParsingError(#[from] crate::variables::VariableParsingError),
|
|
|
|
|
2020-10-04 21:32:50 +00:00
|
|
|
#[error("legacy parsing error")]
|
|
|
|
NomParserError(nom::error::ErrorKind),
|
|
|
|
|
|
|
|
#[error("legacy parsing error: not enough data")]
|
|
|
|
NomParserIncomplete,
|
|
|
|
|
|
|
|
#[error("variables not yet supported")]
|
|
|
|
VariablesNotSupported,
|
2020-10-15 16:52:08 +00:00
|
|
|
|
|
|
|
#[error("database error")]
|
2021-02-03 23:26:41 +00:00
|
|
|
DatabaseError(#[from] sled::Error),
|
2021-02-02 21:41:16 +00:00
|
|
|
|
|
|
|
#[error("too many commands or message was too large")]
|
|
|
|
MessageTooLarge,
|
2020-09-28 21:35:05 +00:00
|
|
|
}
|
2020-11-04 20:09:39 +00:00
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum DiceRollingError {
|
|
|
|
#[error("variable not found: {0}")]
|
|
|
|
VariableNotFound(String),
|
|
|
|
|
|
|
|
#[error("invalid amount")]
|
|
|
|
InvalidAmount,
|
|
|
|
|
|
|
|
#[error("dice pool expression too large")]
|
|
|
|
ExpressionTooLarge,
|
|
|
|
}
|