Error

Struct Error 

Source
pub struct Error { /* private fields */ }
Expand description

An error that can occur in Toasty.

Implementations§

Source§

impl Error

Source

pub fn from_args<'a>(message: Arguments<'a>) -> Error

Creates an error from a format string.

§Examples
use toasty_core::Error;

let err = Error::from_args(format_args!("value {} is invalid", "foo"));
Source

pub fn is_adhoc(&self) -> bool

Returns true if this error is an adhoc error.

Source§

impl Error

Source

pub fn condition_failed(context: impl Into<String>) -> Error

Creates a condition failed error.

This is used when a conditional operation’s condition evaluates to false, such as:

  • An UPDATE with a WHERE clause that matches no rows
  • A DynamoDB conditional write that fails
  • An optimistic lock version check that fails

The context parameter provides information about what condition failed.

Source

pub fn is_condition_failed(&self) -> bool

Returns true if this error is a condition failed error.

Source§

impl Error

Source

pub fn connection_pool(err: impl Error + Send + Sync + 'static) -> Error

Creates an error from a connection pool error.

This is used for errors that occur when managing the connection pool (e.g., deadpool errors).

Source

pub fn is_connection_pool(&self) -> bool

Returns true if this error is a connection pool error.

Source§

impl Error

Source

pub fn driver_operation_failed(err: impl Error + Send + Sync + 'static) -> Error

Creates an error from a driver operation failure.

This is the preferred way to convert driver-specific errors (rusqlite, tokio-postgres, mysql_async, AWS SDK errors, etc.) into toasty errors.

Source

pub fn is_driver_operation_failed(&self) -> bool

Returns true if this error is a driver operation failure.

Source§

impl Error

Source

pub fn expression_evaluation_failed(message: impl Into<String>) -> Error

Creates an expression evaluation failed error.

This is used when expression evaluation fails at runtime due to:

  • Missing context or data
  • Type mismatches
  • Non-evaluable constructs
Source

pub fn is_expression_evaluation_failed(&self) -> bool

Returns true if this error is an expression evaluation failure.

Source§

impl Error

Source§

impl Error

Source

pub fn invalid_driver_configuration(message: impl Into<String>) -> Error

Creates an invalid driver configuration error.

This is used when a driver’s capability configuration is invalid or inconsistent. These errors indicate a bug in the driver implementation.

Source

pub fn is_invalid_driver_configuration(&self) -> bool

Returns true if this error is an invalid driver configuration error.

Source§

impl Error

Source

pub fn invalid_record_count(context: impl Into<String>) -> Error

Creates an invalid record count error.

This is used when an operation expects exactly one record but finds multiple.

The context parameter provides information about the operation.

Source

pub fn is_invalid_record_count(&self) -> bool

Returns true if this error is an invalid record count error.

Source§

impl Error

Source

pub fn invalid_result(message: impl Into<String>) -> Error

Creates an invalid result error.

This is used when a query result has an unexpected structure - the database returned valid data, but its shape doesn’t match what the operation expected.

Source

pub fn is_invalid_result(&self) -> bool

Returns true if this error is an invalid result error.

Source§

impl Error

Source

pub fn invalid_schema(message: impl Into<String>) -> Error

Creates an invalid schema error.

This is used when a schema definition is invalid - duplicate names, invalid column configurations, incompatible features, etc. These errors are typically caught at build/migration time.

Source

pub fn is_invalid_schema(&self) -> bool

Returns true if this error is an invalid schema error.

Source§

impl Error

Source

pub fn invalid_statement(message: impl Into<String>) -> Error

Creates an invalid statement error.

This is used when a statement is malformed or references invalid schema elements. These errors occur during statement lowering/execution at runtime.

Source

pub fn is_invalid_statement(&self) -> bool

Returns true if this error is an invalid statement error.

Source§

impl Error

Source

pub fn type_conversion(value: Value, to_type: &'static str) -> Error

Creates a type conversion error.

This is used when a value cannot be converted to the expected type.

Source

pub fn is_type_conversion(&self) -> bool

Returns true if this error is a type conversion error.

Source§

impl Error

Source

pub fn read_only_transaction(message: impl Into<String>) -> Error

Creates a read-only transaction error.

Returned when a write operation is attempted inside a read-only transaction (e.g. PostgreSQL SQLSTATE 25006, MySQL error 1792).

Source

pub fn is_read_only_transaction(&self) -> bool

Returns true if this error is a read-only transaction error.

Source§

impl Error

Source

pub fn record_not_found(context: impl Into<String>) -> Error

Creates a record not found error.

This is the root cause error when a record lookup (by query or key) returns no results.

The context parameter provides immediate context about what was not found. Additional context can be added at each layer via .context().

§Examples
use toasty_core::Error;

// With context describing what wasn't found (string literal)
let err = Error::record_not_found("table=users key={id: 123}");
assert_eq!(err.to_string(), "record not found: table=users key={id: 123}");

// With context from format! or String
let table = "users";
let key = 123;
let err = Error::record_not_found(format!("table={} key={}", table, key));
assert_eq!(err.to_string(), "record not found: table=users key=123");
Source

pub fn is_record_not_found(&self) -> bool

Returns true if this error is a record not found error.

Source§

impl Error

Source

pub fn serialization_failure(message: impl Into<String>) -> Error

Creates a serialization failure error.

Returned when the database aborts a transaction due to a serialization conflict (e.g. PostgreSQL SQLSTATE 40001, MySQL error 1213).

Source

pub fn is_serialization_failure(&self) -> bool

Returns true if this error is a serialization failure.

Source§

impl Error

Source

pub fn transaction_timeout(duration: Duration) -> Error

Returned when the transaction closure exceeds the configured timeout. The transaction is automatically rolled back.

Source

pub fn is_transaction_timeout(&self) -> bool

Returns true if this error is a transaction timeout.

Source§

impl Error

Source

pub fn unsupported_feature(message: impl Into<String>) -> Error

Creates an unsupported feature error.

This is used when a database does not support a requested feature, such as a specific type, storage constraint, or capability.

Source

pub fn is_unsupported_feature(&self) -> bool

Returns true if this error is an unsupported feature error.

Source§

impl Error

Source

pub fn validation_failed(message: impl Into<String>) -> Error

Creates a general validation error.

Source

pub fn validation_length( value_len: usize, min: Option<usize>, max: Option<usize>, ) -> Error

Creates a validation error for a length constraint violation.

This is used when a string value violates minimum or maximum length constraints.

Source

pub fn is_validation(&self) -> bool

Returns true if this error is a validation error.

Source§

impl Error

Source

pub fn context(self, consequent: impl IntoError) -> Error

Adds context to this error.

Context is displayed in reverse order: the most recently added context is shown first, followed by earlier context, ending with the root cause.

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

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin 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<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> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V