pub struct QueryError { /* private fields */ }core only.Expand description
An error produced by a query or mutation operation.
Implements std::error::Error so it can be used with ? propagation
and libraries like anyhow.
The internal message uses Arc<str> so cloning is cheap, making this
suitable for high-retry scenarios where the same error is stored in
multiple locations.
§Example
use gpui_query::QueryError;
let err = QueryError::response("not found");
assert_eq!(err.to_string(), "response error: not found");§Security
Error messages are included in debug/display output and may be serialized.
When constructing errors from server responses, sanitize the message first
or use QueryError::sanitized.
Implementations§
Source§impl QueryError
impl QueryError
Sourcepub fn new(kind: QueryErrorKind, message: impl Into<Arc<str>>) -> Self
pub fn new(kind: QueryErrorKind, message: impl Into<Arc<str>>) -> Self
Create a new error with the given kind and message.
Sourcepub fn transport(message: impl Into<Arc<str>>) -> Self
pub fn transport(message: impl Into<Arc<str>>) -> Self
Create a transport error (network, timeout).
Sourcepub fn kind(&self) -> QueryErrorKind
pub fn kind(&self) -> QueryErrorKind
The kind of error.
Sourcepub fn message_arc(&self) -> &Arc<str> ⓘ
pub fn message_arc(&self) -> &Arc<str> ⓘ
Returns a reference to the inner Arc<str> message, allowing cheap
clones of the message without re-allocation.
Sourcepub fn sanitized(&self) -> Self
pub fn sanitized(&self) -> Self
Return a sanitized copy of this error with known sensitive patterns redacted.
Redacts common patterns such as:
- Database connection strings (
postgres://...,mysql://...) - Bearer / token headers (
Bearer ...,token=...) - File paths (
/home/...,/Users/...,/etc/...) - Email-like strings
- Long hex sequences (likely API keys)
Also truncates the message to SANITIZE_MAX_LEN bytes.
Trait Implementations§
Source§impl AsRef<str> for QueryError
impl AsRef<str> for QueryError
Source§impl Clone for QueryError
impl Clone for QueryError
Source§fn clone(&self) -> QueryError
fn clone(&self) -> QueryError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QueryError
impl Debug for QueryError
Source§impl<'de> Deserialize<'de> for QueryError
impl<'de> Deserialize<'de> for QueryError
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for QueryError
impl Display for QueryError
impl Eq for QueryError
Source§impl Error for QueryError
impl Error for QueryError
1.30.0 · 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()
Source§impl From<&str> for QueryError
impl From<&str> for QueryError
Source§fn from(value: &str) -> Self
fn from(value: &str) -> Self
Creates a QueryError with kind QueryErrorKind::Unknown.
See From<String> for rationale on the Unknown mapping.
Source§impl From<String> for QueryError
impl From<String> for QueryError
Source§fn from(value: String) -> Self
fn from(value: String) -> Self
Creates a QueryError with kind QueryErrorKind::Unknown.
From<String> and From<&str> always map to Unknown because the
original error category cannot be recovered from a plain string. Use
QueryError::transport, QueryError::response, or
QueryError::cancelled for typed errors.
Source§impl PartialEq for QueryError
impl PartialEq for QueryError
Source§impl Serialize for QueryError
impl Serialize for QueryError
impl StructuralPartialEq for QueryError
Auto Trait Implementations§
impl Freeze for QueryError
impl RefUnwindSafe for QueryError
impl Send for QueryError
impl Sync for QueryError
impl Unpin for QueryError
impl UnsafeUnpin for QueryError
impl UnwindSafe for QueryError
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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