[−][src]Trait sqlx::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 + 'static
[src]
pub fn downcast_ref<T>(&self) -> &T where
T: DatabaseError,
[src]
T: DatabaseError,
Downcast this &dyn DatabaseError
to a specific database error type:
- PgError (if the
postgres
feature is active) - MySqlError (if the
mysql
feature is active) - 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>(&self) -> Option<&T> where
T: DatabaseError,
[src]
T: DatabaseError,
Downcast this &dyn DatabaseError
to a specific database error type:
- PgError (if the
postgres
feature is active) - MySqlError (if the
mysql
feature is active) - 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>(self: Box<dyn DatabaseError + 'static>) -> Box<T> where
T: DatabaseError,
[src]
T: DatabaseError,
Downcast this Box<dyn DatabaseError>
to a specific database error type:
- PgError (if the
postgres
feature is active) - MySqlError (if the
mysql
feature is active) - 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>(
self: Box<dyn DatabaseError + 'static>
) -> Result<Box<T>, Box<dyn DatabaseError + 'static>> where
T: DatabaseError,
[src]
self: Box<dyn DatabaseError + 'static>
) -> Result<Box<T>, Box<dyn DatabaseError + 'static>> where
T: DatabaseError,
Downcast this Box<dyn DatabaseError>
to a specific database error type:
- PgError (if the
postgres
feature is active) - MySqlError (if the
mysql
feature is active) - 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).