pub struct QqlError {
pub kind: ErrorKind,
pub code: Cow<'static, str>,
pub message: Cow<'static, str>,
pub span: Option<Span>,
pub fields: Vec<ErrorField>,
pub source: Option<Box<QqlError>>,
}Expand description
Unified error type for the entire QQL pipeline.
Every error carries:
- a broad
ErrorKindcategory, - a machine-readable
code(e.g.QQL-EDGE-COLLECTION-NOT-FOUND), - a human-readable
message, - an optional source-code
Span, - optional structured
ErrorFields for machine-readable context, and - an optional causal
sourceerror for chaining.
Fields§
§kind: ErrorKindBroad origin category within the pipeline.
code: Cow<'static, str>Machine-readable error code, e.g. QQL-PARSE-SYNTAX.
message: Cow<'static, str>Human-readable description of the failure.
span: Option<Span>Optional source span in the original query text.
fields: Vec<ErrorField>Structured key-value metadata providing machine-readable context
(e.g. collection, status_code, field_name, url).
source: Option<Box<QqlError>>Causal error that led to this one (error chaining).
Implementations§
Source§impl QqlError
impl QqlError
Sourcepub fn new(
kind: ErrorKind,
code: impl Into<Cow<'static, str>>,
message: impl Into<Cow<'static, str>>,
span: Option<Span>,
) -> Self
pub fn new( kind: ErrorKind, code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Option<Span>, ) -> Self
Build an error with an explicit kind, code, message, and optional span.
Sourcepub fn lex(
code: impl Into<Cow<'static, str>>,
message: impl Into<Cow<'static, str>>,
span: Span,
) -> Self
pub fn lex( code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Span, ) -> Self
Create an error with ErrorKind::Lex and the given source span.
Sourcepub fn parse(
code: impl Into<Cow<'static, str>>,
message: impl Into<Cow<'static, str>>,
span: Span,
) -> Self
pub fn parse( code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Span, ) -> Self
Create an error with ErrorKind::Parse and the given source span.
Sourcepub fn validation(
code: impl Into<Cow<'static, str>>,
message: impl Into<Cow<'static, str>>,
span: Option<Span>,
) -> Self
pub fn validation( code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Option<Span>, ) -> Self
Create an error with ErrorKind::Validation and an optional span.
Sourcepub fn execution(
code: impl Into<Cow<'static, str>>,
message: impl Into<Cow<'static, str>>,
span: Option<Span>,
) -> Self
pub fn execution( code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Option<Span>, ) -> Self
Create an error with ErrorKind::Execution and an optional span.
Sourcepub fn transport(
code: impl Into<Cow<'static, str>>,
message: impl Into<Cow<'static, str>>,
span: Option<Span>,
) -> Self
pub fn transport( code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Option<Span>, ) -> Self
Create an error with ErrorKind::Transport and an optional span.
Sourcepub fn backend(
code: impl Into<Cow<'static, str>>,
message: impl Into<Cow<'static, str>>,
span: Option<Span>,
) -> Self
pub fn backend( code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Option<Span>, ) -> Self
Create an error with ErrorKind::Backend and an optional span.
Sourcepub fn with_field(
self,
key: impl Into<Cow<'static, str>>,
value: impl Into<Cow<'static, str>>,
) -> Self
pub fn with_field( self, key: impl Into<Cow<'static, str>>, value: impl Into<Cow<'static, str>>, ) -> Self
Attach a structured key-value metadata field.
let err = QqlError::backend("QQL-BACKEND", "unexpected status", None)
.with_field("status_code", "404")
.with_field("collection", "my_collection");
assert_eq!(err.field("status_code"), Some("404"));
assert_eq!(err.field("collection"), Some("my_collection"));Sourcepub fn with_collection(self, name: impl Into<Cow<'static, str>>) -> Self
pub fn with_collection(self, name: impl Into<Cow<'static, str>>) -> Self
Shorthand for .with_field("collection", name).
Sourcepub fn with_status(self, code: u16) -> Self
pub fn with_status(self, code: u16) -> Self
Shorthand for .with_field("status_code", code).
Sourcepub fn with_url(self, url: impl Into<Cow<'static, str>>) -> Self
pub fn with_url(self, url: impl Into<Cow<'static, str>>) -> Self
Shorthand for .with_field("url", url).
Sourcepub fn with_field_name(self, name: impl Into<Cow<'static, str>>) -> Self
pub fn with_field_name(self, name: impl Into<Cow<'static, str>>) -> Self
Shorthand for .with_field("field_name", name).
Sourcepub fn with_index_name(self, name: impl Into<Cow<'static, str>>) -> Self
pub fn with_index_name(self, name: impl Into<Cow<'static, str>>) -> Self
Shorthand for .with_field("index_name", name).
Sourcepub fn with_vector_name(self, name: impl Into<Cow<'static, str>>) -> Self
pub fn with_vector_name(self, name: impl Into<Cow<'static, str>>) -> Self
Shorthand for .with_field("vector_name", name).
Sourcepub fn with_model(self, name: impl Into<Cow<'static, str>>) -> Self
pub fn with_model(self, name: impl Into<Cow<'static, str>>) -> Self
Shorthand for .with_field("model", name).
Sourcepub fn caused_by(self, source: QqlError) -> Self
pub fn caused_by(self, source: QqlError) -> Self
Chain a causal error.
The source error will be displayed when the outer error is printed
and is accessible via std::error::Error::source.
Trait Implementations§
impl Eq for QqlError
Source§impl Error for QqlError
impl Error for QqlError
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()