2021-05-21 14:21:22 +00:00
|
|
|
use crate::commands::CommandError;
|
2020-10-16 12:40:25 +00:00
|
|
|
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,
|
|
|
|
|
2021-02-07 14:21:28 +00:00
|
|
|
#[error("could not retrieve device id")]
|
|
|
|
NoDeviceIdFound,
|
|
|
|
|
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),
|
|
|
|
|
2021-05-16 21:39:19 +00:00
|
|
|
#[error("uncategorized matrix SDK error: {0}")]
|
2020-09-28 21:35:05 +00:00
|
|
|
MatrixError(#[from] matrix_sdk::Error),
|
|
|
|
|
2021-05-16 21:39:19 +00:00
|
|
|
#[error("uncategorized matrix SDK base error: {0}")]
|
2020-09-28 21:35:05 +00:00
|
|
|
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}")]
|
2021-05-21 14:44:03 +00:00
|
|
|
DiceParsingError(#[from] crate::parser::dice::DiceParsingError),
|
2020-10-31 13:52:46 +00:00
|
|
|
|
|
|
|
#[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}")]
|
2021-05-21 14:44:03 +00:00
|
|
|
VariableParsingError(#[from] crate::parser::variables::VariableParsingError),
|
2020-10-15 16:52:08 +00:00
|
|
|
|
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
|
|
|
|
2021-02-02 21:41:16 +00:00
|
|
|
#[error("too many commands or message was too large")]
|
|
|
|
MessageTooLarge,
|
2021-05-13 20:52:01 +00:00
|
|
|
|
|
|
|
#[error("could not convert to proper integer type")]
|
|
|
|
TryFromIntError(#[from] std::num::TryFromIntError),
|
2021-05-21 22:01:52 +00:00
|
|
|
|
|
|
|
#[error("identifier error: {0}")]
|
|
|
|
IdentifierError(#[from] matrix_sdk::identifiers::Error),
|
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,
|
|
|
|
}
|