#[non_exhaustive]pub enum KernelError {
Parse {
errors: Vec<ParseError>,
message: String,
},
Validation {
issues: Vec<ValidationIssue>,
message: String,
},
Execution(Error),
}Expand description
Why a call to crate::kernel::Kernel::execute (or a sibling —
execute_with_options, execute_argv, …) did not return a result.
The essential distinction is rejected before running versus failed
while running. KernelError::is_rejected answers that question
without inspecting Display text; match on the variant for the finer
detail each rejection carries (issue codes, spans, parse locations).
KernelError::ParseandKernelError::Validationare rejections: the kernel never ran a statement.KernelError::Executionmeans a statement started running and something failed partway through — a builtin, the evaluator, an IO fault, or any other error the interpreter propagated.
Display on every variant reproduces exactly what Kernel::execute
returned before this type existed, so a caller that only prints the
error sees no change on upgrade.
#[non_exhaustive]: a rejection reason can be added later — a refused
external command is one candidate under discussion — without breaking a
caller that already has a wildcard arm. Add a match arm rather than
expect this list to stay closed.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Parse
The input did not lex or parse. Nothing ran.
Fields
errors: Vec<ParseError>Every lex/parse failure found, in source order. Each carries its
own span; errors[i].format(source) reproduces one line of
message.
Validation
The pre-execution validator rejected the program. Nothing ran.
Fields
issues: Vec<ValidationIssue>Every error-severity issue the validator raised, carrying its
kaish_tool_api::IssueCode,
message, and span. Warnings never appear here — they don’t
prevent execution, so they surface on the successful ExecResult
instead.
Execution(Error)
A statement started running and something failed partway through —
a builtin, the evaluator, dispatch, or an IO fault. Carries the
original error chain unchanged; source() and {:#} still walk it.
Implementations§
Source§impl KernelError
impl KernelError
Sourcepub fn is_rejected(&self) -> bool
pub fn is_rejected(&self) -> bool
The program was rejected before anything ran — a lex/parse failure
(KernelError::Parse) or a validator rejection
(KernelError::Validation). No statement executed, so nothing an
embedder retries would have a different partial side effect.
Sourcepub fn is_execution_failure(&self) -> bool
pub fn is_execution_failure(&self) -> bool
A statement began running and faulted partway through
(KernelError::Execution). The complement of Self::is_rejected.
Trait Implementations§
Source§impl Debug for KernelError
impl Debug for KernelError
Source§impl Display for KernelError
impl Display for KernelError
Source§impl Error for KernelError
impl Error for KernelError
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()
Auto Trait Implementations§
impl Freeze for KernelError
impl RefUnwindSafe for KernelError
impl Send for KernelError
impl Sync for KernelError
impl Unpin for KernelError
impl UnsafeUnpin for KernelError
impl UnwindSafe for KernelError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.