pub enum StorageError {
Show 14 variants
Io(Error),
CorruptData(String),
CorruptCrc {
expected: u32,
actual: u32,
},
WalReplay(String),
CatalogCorrupt(String),
PageCorrupt(String),
InvalidIdentifier(String),
RowTooLarge {
size: usize,
max: usize,
},
ValueTooLarge {
size: usize,
max: usize,
},
OverflowCorrupt(String),
DdlInTransaction {
verb: &'static str,
},
TransactionTooLarge {
pages: usize,
limit_bytes: usize,
},
UniqueConstraintViolation {
table: String,
column: String,
},
UniqueExpressionIndexViolation {
table: String,
expression: String,
},
}Expand description
Structured error type for the storage crate.
Replaces raw io::Error at major public API boundaries (catalog
create/open/flush, WAL replay/append) while remaining backward-
compatible via the From<StorageError> for io::Error direction
(internal callers that still use io::Result can ?-propagate).
Variants§
Io(Error)
CorruptData(String)
CorruptCrc
WalReplay(String)
CatalogCorrupt(String)
PageCorrupt(String)
InvalidIdentifier(String)
RowTooLarge
An encoded row exceeds the single-page capacity. Returned cleanly at
the heap insert/update boundary instead of panicking — with
panic = "abort" a panic here would take down the whole server.
ValueTooLarge
A single value exceeds MAX_VALUE_SIZE (the config-raisable 64MB
engine limit on out-of-line values). Distinct from RowTooLarge,
which is the physical single-page inline cap.
OverflowCorrupt(String)
An overflow chain failed to reassemble into the value the stub promised: either the whole-value CRC32 did not match (torn or cross-linked chain) or the chain length disagreed with the stub’s total_len. Surfaces as a typed error at read time.
DdlInTransaction
A DDL statement was issued inside an explicit transaction. DDL is not transactional: it unlinks files and rewrites the catalog immediately, so a later ROLLBACK cannot undo it and would silently destroy data. The statement is refused instead.
TransactionTooLarge
A transaction buffered more unflushed heap pages than the dirty-page
budget allows. The buffer cannot be spilled to disk mid-transaction
without breaking ROLLBACK, so the statement is refused cleanly rather
than growing until the process is OOM-killed (fatal under
panic = "abort").
UniqueConstraintViolation
A write would put a duplicate key into a unique column index. Raised by the insert/update preflight before anything is written, so the heap and every index are left untouched.
UniqueExpressionIndexViolation
The same refusal for a unique expression index (for example a unique
JSON path). Separate from Self::UniqueConstraintViolation because
the offending key is an expression rather than a column, and the
message names it.
Implementations§
Source§impl StorageError
impl StorageError
Sourcepub fn kind(&self) -> StorageErrorKind
pub fn kind(&self) -> StorageErrorKind
This error’s StorageErrorKind.
The match is exhaustive on purpose: a new variant fails to compile until it is classified, which is what stops a refusal a client must act on from silently defaulting to “internal server error”.
Sourcepub fn kind_of_io_error(error: &Error) -> Option<StorageErrorKind>
pub fn kind_of_io_error(error: &Error) -> Option<StorageErrorKind>
Recover the kind of a refusal that crossed an io::Result boundary.
Most of the storage engine’s internals still speak io::Result, and a
typed refusal travels through them as the io::Error’s inner source
(io::Error::new(kind, StorageError::...)). Downcasting back to the
real error is what lets the query layer keep the variant instead of
flattening it to text. Returns None for a plain I/O failure or for a
refusal that was raised as a bare string.
Trait Implementations§
Source§impl Debug for StorageError
impl Debug for StorageError
Source§impl Display for StorageError
impl Display for StorageError
Source§impl Error for StorageError
impl Error for StorageError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()