Skip to main content

KnlError

Enum KnlError 

Source
pub enum KnlError {
    Busy(String),
    Storage(String),
    Corruption(String),
    Closed(String),
    Validation(String),
    Unsupported(String),
    Timeout(String),
    Refused(String),
}
Expand description

What went wrong in the kernel core, classified.

A failure is not one thing. A contended database will succeed if it is asked again; a row that will not decode never will. A caller that passed a negative amount has a bug in its own code; a caller that wrote to a closed handle has finished with the session and needs a new one. Folding all four into one opaque string leaves every caller — the Lua shell most of all — matching on message text to tell them apart, and message text is the one part of an error that is meant to change.

So the variant is the classification, and it is the whole of it: the payload is a human-readable sentence and nothing a caller should branch on. KnlError::kind names the class in one stable word, and KnlError::is_retryable answers the only question whose answer is a program’s rather than a person’s.

The core does not know which Lua method the caller invoked, so the message carries the reason only; the adapter renders the knl: <method>: <kind>: <reason> attribution.

Variants§

§

Busy(String)

Lock contention: the store was busy and the same call may succeed if it is made again. The one retryable class (KnlError::is_retryable).

§

Storage(String)

The store could not do the work — an IO fault, a connection that is gone, an encode failure on the way in. Not busy, so retrying it is a caller’s gamble rather than the kernel’s advice.

§

Corruption(String)

A stored row could not be read back as the event it was written as. Distinct from KnlError::Storage on purpose: the IO succeeded and the bytes came back, so what is wrong is the data, and no retry and no reconnect will change it.

§

Closed(String)

The session is over — this handle closed, or a resume was pointed at a stream whose log already carries its ending. A session is disposable, so the answer is to open another, not to try again.

§

Validation(String)

The caller asked for something the kernel refuses to record: an event that does not meet its kind’s shape, a kernel-only kind, a negative amount, an unknown view or a malformed option. Nothing was written.

§

Unsupported(String)

The request is well-formed but this backend cannot serve it — a query put to a store that keeps no queryable table.

Internal to the SPI: nothing a Lua caller does produces one today. Both sites that raise it are EventStore trait defaults — the query a backend with no table cannot answer, and the two-stream append_if_many a backend with one stream cannot write — and the only backend the product has (SqliteEventStore) overrides both. The shape a caller might expect here answers differently on purpose: an unknown view name is a KnlError::Validation, because the argument was wrong and the message says which.

It stays in the vocabulary all the same, and is published to Lua with the rest (KnlError::KINDS): a store may return it — the trait says so — and a class a backend can produce but a caller was never told about is a class nobody handles. A test double that keeps one stream reaches both defaults today.

§

Timeout(String)

A read ran past the time it was given and was cut short. Distinct from KnlError::Busy on purpose: nothing was contended, the work itself was too slow, so making the same call again buys nothing — what changes the answer is a narrower query or a longer deadline.

§

Refused(String)

A quota did not cover what was asked for, and the refusal was recorded.

The one class that reports a decision rather than a fault. Nothing is wrong: the request was well-formed, the store answered, and the answer is no — Session::open_child raises it when the parent’s balance will not cover the allocation, having written the budget_refused that says so. Distinct from KnlError::Validation because the caller’s arguments were fine, and not retryable, because the same call against the same balance gets the same answer; what changes it is the owner granting more.

Session::reserve does not raise this — it answers false, because a reservation is asked for in a loop that is expected to be told no. An allocation is not: it either produced a child or it did not, and there is no half-opened session to hand back.

Implementations§

Source§

impl KnlError

Source

pub const BUSY: &'static str = "busy"

The stable name of the KnlError::Busy class.

Source

pub const STORAGE: &'static str = "storage"

The stable name of the KnlError::Storage class.

Source

pub const CORRUPTION: &'static str = "corruption"

The stable name of the KnlError::Corruption class.

Source

pub const CLOSED: &'static str = "closed"

The stable name of the KnlError::Closed class.

Source

pub const VALIDATION: &'static str = "validation"

The stable name of the KnlError::Validation class.

Source

pub const UNSUPPORTED: &'static str = "unsupported"

The stable name of the KnlError::Unsupported class.

Source

pub const TIMEOUT: &'static str = "timeout"

The stable name of the KnlError::Timeout class.

Source

pub const REFUSED: &'static str = "refused"

The stable name of the KnlError::Refused class.

Source

pub const KINDS: &'static [&'static str]

Every class a kernel failure can have, in one closed list.

Published so a caller can hold its own error vocabulary against the kernel’s — the Lua bridge hands this to knl.api(), and the shell’s declaration is checked against it rather than against a list somebody retyped.

Source

pub fn kind(&self) -> &'static str

This failure’s class, as one of KnlError::KINDS.

Source

pub fn is_retryable(&self) -> bool

Whether making the same call again could succeed.

True for KnlError::Busy and nothing else. A storage fault might clear, but the kernel does not know that it will, and an error that says “try again” when it means “maybe” is how a retry loop becomes an infinite one.

Source

pub fn kind_is_retryable(kind: &str) -> bool

Whether a class name is the retryable one.

The same answer as KnlError::is_retryable, for a caller that has the word rather than the value — the Lua bridge, which parses a kind back out of an attributed message.

Source

pub fn reason(&self) -> &str

The reason, without the class name or any attribution prefix.

Display writes <kind>: <reason>; this is the second half alone, for a caller that renders the class itself.

Trait Implementations§

Source§

impl Clone for KnlError

Source§

fn clone(&self) -> KnlError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KnlError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for KnlError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for KnlError

Source§

impl Error for KnlError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for KnlError

Classify a rusqlite error into the kernel’s vocabulary.

The store’s own SQL goes through eventsdb, which has its own classification (From<eventsdb_core::Error>); what is left on this path is the SQL the kernel runs itself — the legacy migration’s plain connection (super::logs). The split is the one the caller can act on: a contended lock is KnlError::Busy — the same call may succeed if it is made again — and everything else is KnlError::Storage, a fault the kernel cannot promise anything about. Matched on the SQLite error code, never the message text, so the classification does not drift with a library’s wording.

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for KnlError

Translate the store’s failure into the kernel’s vocabulary.

One class each, because the two vocabularies were drawn along the same line — what a caller can do about it — and the six that exist on both sides mean the same thing on both sides. The message travels as it was written: it is the reason, and the kernel renders the class itself.

The rest go to KnlError::Storage with their text. Truncated, HeadMismatch, and the two retention refusals are answers to calls this kernel does not make — nothing here removes history, and no append names the head it expects — so a caller meeting one is meeting the store failing to do the work, which is what Storage says. The enum is #[non_exhaustive], so a class added later lands there too rather than failing to compile.

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for KnlError

Source§

fn eq(&self, other: &KnlError) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KnlError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<E> ExternalError for E
where E: Into<Box<dyn Error>>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more