pub struct QueryError(/* private fields */);Expand description
Structured native-engine error with stable classification and facts.
Implementations§
Source§impl QueryError
impl QueryError
Sourcepub fn new(
code: QueryErrorCode,
operation: &'static str,
message: impl Into<String>,
) -> Self
pub fn new( code: QueryErrorCode, operation: &'static str, message: impl Into<String>, ) -> Self
Creates a native-engine error with a stable operation id and message.
operation should be a stable dotted identifier such as
query_engine.plan.execute. message is human-facing diagnostic
text. Add machine-readable context with Self::with_fact.
§Panics
Panics when operation or message is empty. Construction-time
identity must be present; later decoration (Self::with_fact,
Self::with_source) never panics and keeps the first value.
Sourcepub fn with_fact(self, key: &'static str, value: impl ToString) -> Self
pub fn with_fact(self, key: &'static str, value: impl ToString) -> Self
Adds one machine-readable fact.
key must be a non-empty static string and should be treated as part of
the diagnostic contract once exposed. value is stringified with
ToString. A duplicate or empty key never panics and never replaces
the primary error’s facts. The first value wins, and the rejected key is
recorded under the fact_collision_keys fact. Layered with_fact calls must
therefore use distinct keys per layer; wrapping an error must not
re-emit a key the wrapped error already owns.
Sourcepub fn context(&self) -> &FailureContext
pub fn context(&self) -> &FailureContext
Returns the typed failure evidence that decisions read.
Sourcepub fn with_memory_failure(self, memory: MemoryFailure) -> Self
pub fn with_memory_failure(self, memory: MemoryFailure) -> Self
Records the budget scope the failure passed through. The innermost scope wins; a different later scope is reported as a fact collision.
Sourcepub fn with_resource_boundary(self, boundary: ResourceBoundary) -> Self
pub fn with_resource_boundary(self, boundary: ResourceBoundary) -> Self
Records the execution boundary that owned the failed work. The first complete boundary wins as a unit, so an outer scope never pairs its node or side with an inner failure location.
Sourcepub fn wire_facts(&self) -> impl Iterator<Item = (&'static str, Cow<'_, str>)>
pub fn wire_facts(&self) -> impl Iterator<Item = (&'static str, Cow<'_, str>)>
Stored diagnostic facts plus the typed context rendered under its wire keys, sorted by key.
The typed value wins over a stored fact with the same key; a stored
fact that disagrees is reported under fact_collision_keys.
Sourcepub fn with_query_id(self, query_id: impl Into<QueryId>) -> Self
pub fn with_query_id(self, query_id: impl Into<QueryId>) -> Self
Assigns a query-wide diagnostic correlation id and mirrors it into facts.
Sourcepub fn with_trace_id(self, trace_id: impl Into<TraceId>) -> Self
pub fn with_trace_id(self, trace_id: impl Into<TraceId>) -> Self
Assigns an optional parent trace id and mirrors it into facts.
Sourcepub fn with_source<E>(self, source: E) -> Self
pub fn with_source<E>(self, source: E) -> Self
Attaches the source error when no source is already present.
A second source is discarded so error decoration cannot replace the
original causal chain. Layers that need to add context wrap the error
in a new QueryError and do not re-attach a source.
Sourcepub fn code(&self) -> QueryErrorCode
pub fn code(&self) -> QueryErrorCode
Returns the stable machine-readable error code.
Sourcepub fn kind(&self) -> QueryErrorKind
pub fn kind(&self) -> QueryErrorKind
Returns the coarse category derived from Self::code.
Sourcepub fn status(&self) -> QueryErrorStatus
pub fn status(&self) -> QueryErrorStatus
Returns the retry/remediation status derived from Self::code.
Sourcepub fn query_id(&self) -> Option<&QueryId>
pub fn query_id(&self) -> Option<&QueryId>
Returns the query-wide diagnostic correlation id, when assigned.
Sourcepub fn trace_id(&self) -> Option<&TraceId>
pub fn trace_id(&self) -> Option<&TraceId>
Returns the optional parent trace id, when assigned.
Sourcepub fn operation(&self) -> &'static str
pub fn operation(&self) -> &'static str
Returns the stable dotted operation id that produced the error.
Sourcepub fn fact_value(&self, key: &str) -> Option<&str>
pub fn fact_value(&self, key: &str) -> Option<&str>
Returns a stored fact by name. Typed failure-context projections are
available through Self::wire_facts.
Sourcepub fn source_error(&self) -> Option<&(dyn StdError + 'static)>
pub fn source_error(&self) -> Option<&(dyn StdError + 'static)>
Returns the underlying source error when one was attached.
Source§impl QueryError
impl QueryError
Sourcepub fn triage_summary(&self) -> TriageSummary
pub fn triage_summary(&self) -> TriageSummary
Builds a compact triage summary for this error.
Structured context takes precedence over facts. The error’s own query id
and boundary node id are used first, and the query_id and node_id
facts fill in only when the context lacks them. The compiled_task_id
fact is used whenever it is present.
Trait Implementations§
Source§impl Clone for QueryError
impl Clone for QueryError
Source§impl Debug for QueryError
impl Debug for QueryError
Source§impl Display for QueryError
impl Display for QueryError
Source§impl Error for QueryError
impl Error for QueryError
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()