pub struct Error { /* private fields */ }Expand description
Represents an error in SurrealDB
Designed to be returned from public APIs (including over the wire). It is
wire-friendly and non-lossy: serialization preserves kind, message,
and optional details. Use this type whenever an error crosses
an API boundary (e.g. server response, SDK method return).
The details field is flattened into the serialized object, so the wire
format contains kind (string) and optionally details (object) at the
same level as code and message. The optional cause field allows
error chaining so that SDKs can receive and display full error chains.
Implementations§
Source§impl Error
impl Error
Sourcepub fn validation(
message: String,
details: impl Into<Option<ValidationError>>,
) -> Error
pub fn validation( message: String, details: impl Into<Option<ValidationError>>, ) -> Error
Validation error (parse error, invalid request or params), with optional structured details.
When details is provided, the wire code is set from the variant (e.g. Parse →
PARSE_ERROR).
Sourcepub fn not_allowed(
message: String,
details: impl Into<Option<NotAllowedError>>,
) -> Error
pub fn not_allowed( message: String, details: impl Into<Option<NotAllowedError>>, ) -> Error
Not-allowed error (e.g. method, scripting, function, net target), with optional
structured details. When details is provided, the wire code is set from the variant.
Sourcepub fn configuration(
message: String,
details: impl Into<Option<ConfigurationError>>,
) -> Error
pub fn configuration( message: String, details: impl Into<Option<ConfigurationError>>, ) -> Error
Configuration error (feature or config not supported), with optional structured details.
When details is provided, the wire code is set from the variant.
Sourcepub fn thrown(message: String) -> Error
pub fn thrown(message: String) -> Error
User-thrown error (e.g. from THROW in SurrealQL). Sets wire code for RPC.
Sourcepub fn query(message: String, details: impl Into<Option<QueryError>>) -> Error
pub fn query(message: String, details: impl Into<Option<QueryError>>) -> Error
Query execution error (not executed, timeout, cancelled), with optional structured details.
When details is provided, the wire code is set from the variant.
Sourcepub fn serialization(
message: String,
details: impl Into<Option<SerializationError>>,
) -> Error
pub fn serialization( message: String, details: impl Into<Option<SerializationError>>, ) -> Error
Serialisation or deserialisation error, with optional structured details.
When details is provided, the wire code is set from the variant.
Sourcepub fn not_found(
message: String,
details: impl Into<Option<NotFoundError>>,
) -> Error
pub fn not_found( message: String, details: impl Into<Option<NotFoundError>>, ) -> Error
Resource not found (e.g. table, record, namespace, RPC method), with optional
structured details. When details is NotFoundError::Method, the wire code is set to
METHOD_NOT_FOUND for RPC backwards compatibility.
Sourcepub fn already_exists(
message: String,
details: impl Into<Option<AlreadyExistsError>>,
) -> Error
pub fn already_exists( message: String, details: impl Into<Option<AlreadyExistsError>>, ) -> Error
Resource already exists (e.g. table, record), with optional structured details.
Sourcepub fn connection(
message: String,
details: impl Into<Option<ConnectionError>>,
) -> Error
pub fn connection( message: String, details: impl Into<Option<ConnectionError>>, ) -> Error
Connection error (e.g. uninitialised, already connected), with optional structured details. Used in the SDK for client-side connection state errors.
Sourcepub fn internal(message: String) -> Error
pub fn internal(message: String) -> Error
Internal or unexpected error (server or client). Sets wire code for RPC.
Sourcepub fn cause(&self) -> Option<&Error>
pub fn cause(&self) -> Option<&Error>
Returns the optional underlying cause for error chaining.
Sourcepub fn with_cause(self, cause: Error) -> Error
pub fn with_cause(self, cause: Error) -> Error
Returns an error with the given cause attached. Consumes self.
Sourcepub fn kind_str(&self) -> &'static str
pub fn kind_str(&self) -> &'static str
Returns the kind string for this error (e.g. “NotAllowed”, “Internal”).
Sourcepub fn details(&self) -> &ErrorDetails
pub fn details(&self) -> &ErrorDetails
Returns the error details (always present). The variant determines the error kind.
Sourcepub fn is_validation(&self) -> bool
pub fn is_validation(&self) -> bool
Returns true if this is a validation error.
Sourcepub fn is_configuration(&self) -> bool
pub fn is_configuration(&self) -> bool
Returns true if this is a configuration error.
Sourcepub fn is_serialization(&self) -> bool
pub fn is_serialization(&self) -> bool
Returns true if this is a serialization error.
Sourcepub fn is_not_allowed(&self) -> bool
pub fn is_not_allowed(&self) -> bool
Returns true if this is a not-allowed error.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Returns true if this is a not-found error.
Sourcepub fn is_already_exists(&self) -> bool
pub fn is_already_exists(&self) -> bool
Returns true if this is an already-exists error.
Sourcepub fn is_connection(&self) -> bool
pub fn is_connection(&self) -> bool
Returns true if this is a connection error.
Sourcepub fn is_internal(&self) -> bool
pub fn is_internal(&self) -> bool
Returns true if this is an internal error.
Sourcepub fn validation_details(&self) -> Option<&ValidationError>
pub fn validation_details(&self) -> Option<&ValidationError>
Returns structured validation error details, if this is a validation error with specifics.
Sourcepub fn not_allowed_details(&self) -> Option<&NotAllowedError>
pub fn not_allowed_details(&self) -> Option<&NotAllowedError>
Returns structured not-allowed error details, if this is a not-allowed error with specifics.
Sourcepub fn configuration_details(&self) -> Option<&ConfigurationError>
pub fn configuration_details(&self) -> Option<&ConfigurationError>
Returns structured configuration error details, if this is a configuration error with specifics.
Sourcepub fn serialization_details(&self) -> Option<&SerializationError>
pub fn serialization_details(&self) -> Option<&SerializationError>
Returns structured serialization error details, if this is a serialization error with specifics.
Sourcepub fn not_found_details(&self) -> Option<&NotFoundError>
pub fn not_found_details(&self) -> Option<&NotFoundError>
Returns structured not-found error details, if this is a not-found error with specifics.
Sourcepub fn query_details(&self) -> Option<&QueryError>
pub fn query_details(&self) -> Option<&QueryError>
Returns structured query error details, if this is a query error with specifics.
Sourcepub fn already_exists_details(&self) -> Option<&AlreadyExistsError>
pub fn already_exists_details(&self) -> Option<&AlreadyExistsError>
Returns structured already-exists error details, if this is an already-exists error with specifics.
Sourcepub fn connection_details(&self) -> Option<&ConnectionError>
pub fn connection_details(&self) -> Option<&ConnectionError>
Returns structured connection error details, if this is a connection error with specifics.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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
Source§impl From<ConversionError> for Error
impl From<ConversionError> for Error
Source§fn from(e: ConversionError) -> Error
fn from(e: ConversionError) -> Error
Source§impl From<LengthMismatchError> for Error
impl From<LengthMismatchError> for Error
Source§fn from(e: LengthMismatchError) -> Error
fn from(e: LengthMismatchError) -> Error
Source§impl From<OutOfRangeError> for Error
impl From<OutOfRangeError> for Error
Source§fn from(e: OutOfRangeError) -> Error
fn from(e: OutOfRangeError) -> Error
Source§impl SurrealValue for Error
impl SurrealValue for Error
impl Eq for Error
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoVariables for Twhere
T: SurrealValue,
impl<T> IntoVariables for Twhere
T: SurrealValue,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
Source§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
Source§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
Source§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Source§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.