Skip to main content

Error

Struct Error 

Source
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

Source

pub fn validation( message: String, details: impl Into<Option<ValidationError>>, ) -> Self

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. ParsePARSE_ERROR).

Source

pub fn not_allowed( message: String, details: impl Into<Option<NotAllowedError>>, ) -> Self

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.

Source

pub fn configuration( message: String, details: impl Into<Option<ConfigurationError>>, ) -> Self

Configuration error (feature or config not supported), with optional structured details. When details is provided, the wire code is set from the variant.

Source

pub fn thrown(message: String) -> Self

User-thrown error (e.g. from THROW in SurrealQL). Sets wire code for RPC.

Source

pub fn query(message: String, details: impl Into<Option<QueryError>>) -> Self

Query execution error (not executed, timeout, cancelled), with optional structured details. When details is provided, the wire code is set from the variant.

Source

pub fn serialization( message: String, details: impl Into<Option<SerializationError>>, ) -> Self

Serialisation or deserialisation error, with optional structured details. When details is provided, the wire code is set from the variant.

Source

pub fn not_found( message: String, details: impl Into<Option<NotFoundError>>, ) -> Self

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.

Source

pub fn already_exists( message: String, details: impl Into<Option<AlreadyExistsError>>, ) -> Self

Resource already exists (e.g. table, record), with optional structured details.

Source

pub fn connection( message: String, details: impl Into<Option<ConnectionError>>, ) -> Self

Connection error (e.g. uninitialised, already connected), with optional structured details. Used in the SDK for client-side connection state errors.

Source

pub fn internal(message: String) -> Self

Internal or unexpected error (server or client). Sets wire code for RPC.

Source

pub fn cause(&self) -> Option<&Error>

Returns the optional underlying cause for error chaining.

Source

pub fn with_cause(self, cause: Error) -> Self

Returns an error with the given cause attached. Consumes self.

Source

pub fn kind_str(&self) -> &'static str

Returns the kind string for this error (e.g. “NotAllowed”, “Internal”).

Source

pub fn message(&self) -> &str

Returns the human-readable error message.

Source

pub fn details(&self) -> &ErrorDetails

Returns the error details (always present). The variant determines the error kind.

Source

pub fn is_validation(&self) -> bool

Returns true if this is a validation error.

Source

pub fn is_configuration(&self) -> bool

Returns true if this is a configuration error.

Source

pub fn is_query(&self) -> bool

Returns true if this is a query error.

Source

pub fn is_serialization(&self) -> bool

Returns true if this is a serialization error.

Source

pub fn is_not_allowed(&self) -> bool

Returns true if this is a not-allowed error.

Source

pub fn is_not_found(&self) -> bool

Returns true if this is a not-found error.

Source

pub fn is_already_exists(&self) -> bool

Returns true if this is an already-exists error.

Source

pub fn is_connection(&self) -> bool

Returns true if this is a connection error.

Source

pub fn is_thrown(&self) -> bool

Returns true if this is a user-thrown error.

Source

pub fn is_internal(&self) -> bool

Returns true if this is an internal error.

Source

pub fn validation_details(&self) -> Option<&ValidationError>

Returns structured validation error details, if this is a validation error with specifics.

Source

pub fn not_allowed_details(&self) -> Option<&NotAllowedError>

Returns structured not-allowed error details, if this is a not-allowed error with specifics.

Source

pub fn configuration_details(&self) -> Option<&ConfigurationError>

Returns structured configuration error details, if this is a configuration error with specifics.

Source

pub fn serialization_details(&self) -> Option<&SerializationError>

Returns structured serialization error details, if this is a serialization error with specifics.

Source

pub fn not_found_details(&self) -> Option<&NotFoundError>

Returns structured not-found error details, if this is a not-found error with specifics.

Source

pub fn query_details(&self) -> Option<&QueryError>

Returns structured query error details, if this is a query error with specifics.

Source

pub fn already_exists_details(&self) -> Option<&AlreadyExistsError>

Returns structured already-exists error details, if this is an already-exists error with specifics.

Source

pub fn connection_details(&self) -> Option<&ConnectionError>

Returns structured connection error details, if this is a connection error with specifics.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ConversionError> for Error

Source§

fn from(e: ConversionError) -> Self

Converts to this type from the input type.
Source§

impl From<LengthMismatchError> for Error

Source§

fn from(e: LengthMismatchError) -> Self

Converts to this type from the input type.
Source§

impl From<OutOfRangeError> for Error

Source§

fn from(e: OutOfRangeError) -> Self

Converts to this type from the input type.
Source§

impl From<TypeError> for Error

Source§

fn from(e: TypeError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Error) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SurrealValue for Error

Source§

fn into_value(self) -> Value

Converts this type into a SurrealDB value
Source§

fn from_value(value: Value) -> Result<Self, Error>

Attempts to convert a SurrealDB value into this type
Source§

fn is_value(value: &Value) -> bool

Checks if the given value can be converted to this type
Source§

fn kind_of() -> Kind

Returns the kind that represents this type
Source§

impl Eq for Error

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool