Trait sqlx_core::error::DatabaseError [−][src]
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
Provided methods
fn code(&self) -> Option<Cow<'_, str>>
[src]
fn code(&self) -> Option<Cow<'_, str>>
[src]The (SQLSTATE) code for the error.
fn constraint(&self) -> Option<&str>
[src]
fn constraint(&self) -> Option<&str>
[src]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
impl dyn DatabaseError
[src]
impl dyn DatabaseError
[src]pub fn downcast_ref<E: DatabaseError>(&self) -> &E
[src]
pub fn downcast_ref<E: DatabaseError>(&self) -> &E
[src]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
.
pub fn downcast<E: DatabaseError>(self: Box<Self>) -> Box<E>
[src]
pub fn downcast<E: DatabaseError>(self: Box<Self>) -> Box<E>
[src]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
.
pub fn try_downcast_ref<E: DatabaseError>(&self) -> Option<&E>
[src]
pub fn try_downcast_ref<E: DatabaseError>(&self) -> Option<&E>
[src]Downcast a reference to this generic database error to a specific database error type.
pub fn try_downcast<E: DatabaseError>(
self: Box<Self>
) -> StdResult<Box<E>, Box<Self>>
[src]
pub fn try_downcast<E: DatabaseError>(
self: Box<Self>
) -> StdResult<Box<E>, Box<Self>>
[src]Downcast this generic database error to a specific database error type.
Implementors
impl DatabaseError for MssqlDatabaseError
[src]
impl DatabaseError for MssqlDatabaseError
[src]impl DatabaseError for MySqlDatabaseError
[src]
impl DatabaseError for MySqlDatabaseError
[src]impl DatabaseError for PgDatabaseError
[src]
impl DatabaseError for PgDatabaseError
[src]