2021-05-21 14:05:25 +00:00
|
|
|
use std::num::TryFromIntError;
|
2020-10-24 13:08:23 +00:00
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum DataError {
|
|
|
|
#[error("value does not exist for key: {0}")]
|
|
|
|
KeyDoesNotExist(String),
|
|
|
|
|
2020-11-03 20:14:15 +00:00
|
|
|
#[error("too many entries")]
|
|
|
|
TooManyEntries,
|
|
|
|
|
2020-10-24 13:08:23 +00:00
|
|
|
#[error("expected i32, but i32 schema was violated")]
|
|
|
|
I32SchemaViolation,
|
|
|
|
|
2020-11-09 21:14:37 +00:00
|
|
|
#[error("unexpected or corruptd data bytes")]
|
|
|
|
InvalidValue,
|
|
|
|
|
2021-02-07 14:21:28 +00:00
|
|
|
#[error("expected string ref, but utf8 schema was violated: {0}")]
|
|
|
|
Utf8RefSchemaViolation(#[from] std::str::Utf8Error),
|
|
|
|
|
2020-10-24 13:08:23 +00:00
|
|
|
#[error("expected string, but utf8 schema was violated: {0}")]
|
2021-02-07 14:21:28 +00:00
|
|
|
Utf8SchemaViolation(#[from] std::string::FromUtf8Error),
|
2020-10-24 13:08:23 +00:00
|
|
|
|
2020-10-24 13:46:06 +00:00
|
|
|
#[error("data migration error: {0}")]
|
2021-05-21 14:05:25 +00:00
|
|
|
MigrationError(#[from] crate::db::sqlite::migrator::MigrationError),
|
2020-11-03 20:14:15 +00:00
|
|
|
|
2021-05-21 14:21:22 +00:00
|
|
|
#[error("internal database error: {0}")]
|
2021-05-21 14:05:25 +00:00
|
|
|
SqlxError(#[from] sqlx::Error),
|
|
|
|
|
|
|
|
#[error("numeric conversion error")]
|
|
|
|
NumericConversionError(#[from] TryFromIntError),
|
2020-10-24 13:08:23 +00:00
|
|
|
}
|