pub trait DatabaseError: 'static + Send + Sync + StdError {
    fn message(&self) -> &str;

    fn code(&self) -> Option<Cow<'_, str>> { ... }
    fn constraint(&self) -> Option<&str> { ... }
}
Expand description

An error that was returned from the database.

Required Methods

The primary, human-readable error message.

Provided Methods

The (SQLSTATE) code for the error.

Returns the name of the constraint that triggered the error, if applicable. If the error was caused by a conflict of a unique index, this will be the index name.

Note

Currently only populated by the Postgres driver.

Implementations

Downcast a reference to this generic database error to a specific database error type.

Panics

Panics if the database error type is not E. This is a deliberate contrast from Error::downcast_ref which returns Option<&E>. In normal usage, you should know the specific error type. In other cases, use try_downcast_ref.

Downcast this generic database error to a specific database error type.

Panics

Panics if the database error type is not E. This is a deliberate contrast from Error::downcast which returns Option<E>. In normal usage, you should know the specific error type. In other cases, use try_downcast.

Downcast a reference to this generic database error to a specific database error type.

Downcast this generic database error to a specific database error type.

Trait Implementations

The lower-level source of this error, if any. Read more

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Implementors