pub struct Error { /* private fields */ }Expand description
An error that can occur in Toasty.
Implementations§
Source§impl Error
impl Error
Sourcepub fn condition_failed(context: impl Into<String>) -> Error
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.
Sourcepub fn is_condition_failed(&self) -> bool
pub fn is_condition_failed(&self) -> bool
Returns true if this error is a condition failed error.
Source§impl Error
impl Error
Sourcepub fn connection_pool(err: impl Error + Send + Sync + 'static) -> Error
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).
Sourcepub fn is_connection_pool(&self) -> bool
pub fn is_connection_pool(&self) -> bool
Returns true if this error is a connection pool error.
Source§impl Error
impl Error
Sourcepub fn driver_operation_failed(err: impl Error + Send + Sync + 'static) -> Error
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.
Sourcepub fn is_driver_operation_failed(&self) -> bool
pub fn is_driver_operation_failed(&self) -> bool
Returns true if this error is a driver operation failure.
Source§impl Error
impl Error
Sourcepub fn expression_evaluation_failed(message: impl Into<String>) -> Error
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
Sourcepub fn is_expression_evaluation_failed(&self) -> bool
pub fn is_expression_evaluation_failed(&self) -> bool
Returns true if this error is an expression evaluation failure.
Source§impl Error
impl Error
pub fn invalid_connection_url(message: impl Into<String>) -> Error
pub fn is_invalid_connection_url(&self) -> bool
Source§impl Error
impl Error
Sourcepub fn invalid_driver_configuration(message: impl Into<String>) -> Error
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.
Sourcepub fn is_invalid_driver_configuration(&self) -> bool
pub fn is_invalid_driver_configuration(&self) -> bool
Returns true if this error is an invalid driver configuration error.
Source§impl Error
impl Error
Sourcepub fn invalid_record_count(context: impl Into<String>) -> Error
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.
Sourcepub fn is_invalid_record_count(&self) -> bool
pub fn is_invalid_record_count(&self) -> bool
Returns true if this error is an invalid record count error.
Source§impl Error
impl Error
Sourcepub fn invalid_result(message: impl Into<String>) -> Error
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.
Sourcepub fn is_invalid_result(&self) -> bool
pub fn is_invalid_result(&self) -> bool
Returns true if this error is an invalid result error.
Source§impl Error
impl Error
Sourcepub fn invalid_schema(message: impl Into<String>) -> Error
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.
Sourcepub fn is_invalid_schema(&self) -> bool
pub fn is_invalid_schema(&self) -> bool
Returns true if this error is an invalid schema error.
Source§impl Error
impl Error
Sourcepub fn invalid_statement(message: impl Into<String>) -> Error
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.
Sourcepub fn is_invalid_statement(&self) -> bool
pub fn is_invalid_statement(&self) -> bool
Returns true if this error is an invalid statement error.
Source§impl Error
impl Error
Sourcepub fn type_conversion(value: Value, to_type: &'static str) -> Error
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.
Sourcepub fn is_type_conversion(&self) -> bool
pub fn is_type_conversion(&self) -> bool
Returns true if this error is a type conversion error.
Source§impl Error
impl Error
Sourcepub fn read_only_transaction(message: impl Into<String>) -> Error
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).
Sourcepub fn is_read_only_transaction(&self) -> bool
pub fn is_read_only_transaction(&self) -> bool
Returns true if this error is a read-only transaction error.
Source§impl Error
impl Error
Sourcepub fn record_not_found(context: impl Into<String>) -> Error
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");Sourcepub fn is_record_not_found(&self) -> bool
pub fn is_record_not_found(&self) -> bool
Returns true if this error is a record not found error.
Source§impl Error
impl Error
Sourcepub fn serialization_failure(message: impl Into<String>) -> Error
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).
Sourcepub fn is_serialization_failure(&self) -> bool
pub fn is_serialization_failure(&self) -> bool
Returns true if this error is a serialization failure.
Source§impl Error
impl Error
Sourcepub fn transaction_timeout(duration: Duration) -> Error
pub fn transaction_timeout(duration: Duration) -> Error
Returned when the transaction closure exceeds the configured timeout. The transaction is automatically rolled back.
Sourcepub fn is_transaction_timeout(&self) -> bool
pub fn is_transaction_timeout(&self) -> bool
Returns true if this error is a transaction timeout.
Source§impl Error
impl Error
Sourcepub fn unsupported_feature(message: impl Into<String>) -> Error
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.
Sourcepub fn is_unsupported_feature(&self) -> bool
pub fn is_unsupported_feature(&self) -> bool
Returns true if this error is an unsupported feature error.
Source§impl Error
impl Error
Sourcepub fn validation_failed(message: impl Into<String>) -> Error
pub fn validation_failed(message: impl Into<String>) -> Error
Creates a general validation error.
Sourcepub fn validation_length(
value_len: usize,
min: Option<usize>,
max: Option<usize>,
) -> Error
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.
Sourcepub fn is_validation(&self) -> bool
pub fn is_validation(&self) -> bool
Returns true if this error is a validation error.