#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("playlist storage is disabled")]
Disabled,
#[error("playlist {id} not found")]
PlaylistNotFound {
id: mineral_model::PlaylistId,
},
#[error("{operation} failed")]
Database {
operation: &'static str,
#[source]
source: sea_orm::DbErr,
},
#[error("{operation} failed for {record}")]
Record {
operation: &'static str,
record: String,
#[source]
source: sea_orm::DbErr,
},
#[error("{operation} for song {song} key {key} failed")]
Key {
operation: &'static str,
song: String,
key: String,
#[source]
source: sea_orm::DbErr,
},
#[error("{database} schema migration failed; run `mineral cache reset --yes` to rebuild")]
Migration {
database: &'static str,
#[source]
source: sea_orm::DbErr,
},
#[error("duration for {song} cannot fit SQLite")]
Duration {
song: String,
#[source]
source: std::num::TryFromIntError,
},
#[error("numeric value outside supported range")]
Number {
#[from]
source: std::num::TryFromIntError,
},
#[error("reserved KV key: {key}")]
ReservedKey {
key: String,
},
#[error("invalid KV columns for song {song} key {key} type {value_type}")]
InvalidValue {
song: String,
key: String,
value_type: String,
},
#[error("rating {rating} exceeds maximum {max}")]
InvalidRating {
rating: u8,
max: u8,
},
#[error(transparent)]
Storage(#[from] mineral_persist::Error),
#[error("expected source {expected:?}, got {actual:?}")]
NamespaceMismatch {
expected: mineral_model::SourceKind,
actual: mineral_model::SourceKind,
},
}
pub type Result<T> = std::result::Result<T, Error>;