mirror of
https://github.com/lexmount/moli.git
synced 2026-10-07 08:01:00 +00:00
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use std::fmt;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum IndexedDbError {
|
|
Constraint(String),
|
|
InvalidState(String),
|
|
NotFound(String),
|
|
QuotaExceeded { quota: u64, requested: u64 },
|
|
ReadOnly(String),
|
|
TransactionInactive(String),
|
|
Version(String),
|
|
Io(String),
|
|
Corruption(String),
|
|
Serialization(String),
|
|
}
|
|
|
|
impl fmt::Display for IndexedDbError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::Constraint(message)
|
|
| Self::InvalidState(message)
|
|
| Self::NotFound(message)
|
|
| Self::ReadOnly(message)
|
|
| Self::TransactionInactive(message)
|
|
| Self::Version(message)
|
|
| Self::Io(message)
|
|
| Self::Corruption(message)
|
|
| Self::Serialization(message) => f.write_str(message),
|
|
Self::QuotaExceeded { quota, requested } => write!(
|
|
f,
|
|
"IndexedDB write would exceed storage quota: requested {requested} bytes, quota {quota} bytes"
|
|
),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for IndexedDbError {}
|