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: ErrorKind§code: Cow<'static, str>§message: Cow<'static, str>§span: Option<Span>§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
pub fn new( kind: ErrorKind, code: impl Into<Cow<'static, str>>, message: impl Into<Cow<'static, str>>, span: Option<Span>, ) -> Self
pub fn lex( 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
pub fn validation( 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
pub fn transport( 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
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
impl StructuralPartialEq for QqlError
Auto Trait Implementations§
impl Freeze for QqlError
impl RefUnwindSafe for QqlError
impl Send for QqlError
impl Sync for QqlError
impl Unpin for QqlError
impl UnsafeUnpin for QqlError
impl UnwindSafe for QqlError
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
Mutably borrows from an owned value. Read more