[−][src]Trait sqlx_core::error::DatabaseError
An error that was returned by the database.
Required methods
Loading content...Provided methods
fn code(&self) -> Option<&str>
The (SQLSTATE) code for the error.
fn details(&self) -> Option<&str>
fn hint(&self) -> Option<&str>
fn table_name(&self) -> Option<&str>
fn column_name(&self) -> Option<&str>
fn constraint_name(&self) -> Option<&str>
Methods
impl dyn DatabaseError
[src]
pub fn downcast_ref<T: DatabaseError>(&self) -> &T
[src]
Downcast this &dyn DatabaseError
to a specific database error type:
- [PgError][crate::postgres::PgError] (if the
postgres
feature is active) - [MySqlError][crate::mysql::MySqlError] (if the
mysql
feature is active) - [SqliteError][crate::sqlite::SqliteError] (if the
sqlite
feature is active)
In a generic context you can use the crate::database::Database::Error associated type.
Panics
If the type does not match; this is in contrast with [StdError::downcast_ref]
which returns Option
. This was a deliberate design decision in favor of brevity as in
almost all cases you should know which database error type you're expecting.
In any other cases, use [Self::try_downcast_ref] instead.
pub fn try_downcast_ref<T: DatabaseError>(&self) -> Option<&T>
[src]
Downcast this &dyn DatabaseError
to a specific database error type:
- [PgError][crate::postgres::PgError] (if the
postgres
feature is active) - [MySqlError][crate::mysql::MySqlError] (if the
mysql
feature is active) - [SqliteError][crate::sqlite::SqliteError] (if the
sqlite
feature is active)
In a generic context you can use the crate::database::Database::Error associated type.
Returns None
if the downcast fails (the types do not match)
pub fn downcast<T: DatabaseError>(self: Box<Self>) -> Box<T>
[src]
Downcast this Box<dyn DatabaseError>
to a specific database error type:
- [PgError][crate::postgres::PgError] (if the
postgres
feature is active) - [MySqlError][crate::mysql::MySqlError] (if the
mysql
feature is active) - [SqliteError][crate::sqlite::SqliteError] (if the
sqlite
feature is active)
In a generic context you can use the crate::database::Database::Error associated type.
Panics
If the type does not match; this is in contrast with [std::error::Error::downcast]
which returns Result
. This was a deliberate design decision in favor of
brevity as in almost all cases you should know which database error type you're expecting.
In any other cases, use [Self::try_downcast] instead.
pub fn try_downcast<T: DatabaseError>(
self: Box<Self>
) -> Result<Box<T>, Box<Self>>
[src]
self: Box<Self>
) -> Result<Box<T>, Box<Self>>
Downcast this Box<dyn DatabaseError>
to a specific database error type:
- [PgError][crate::postgres::PgError] (if the
postgres
feature is active) - [MySqlError][crate::mysql::MySqlError] (if the
mysql
feature is active) - [SqliteError][crate::sqlite::SqliteError] (if the
sqlite
feature is active)
In a generic context you can use the crate::database::Database::Error associated type.
Returns Err(self)
if the downcast fails (the types do not match).