[][src]Trait sqlx::error::DatabaseError

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

    fn code(&self) -> Option<&str> { ... }
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> { ... } }

An error that was returned by the database.

Required methods

fn message(&self) -> &str

The primary, human-readable error message.

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>

Loading content...

Methods

impl dyn DatabaseError + 'static[src]

pub fn downcast_ref<T>(&self) -> &T where
    T: DatabaseError
[src]

Downcast this &dyn DatabaseError to a specific database error type:

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]

Downcast this &dyn DatabaseError to a specific database error type:

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]

Downcast this Box<dyn DatabaseError> to a specific database error type:

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]

Downcast this Box<dyn DatabaseError> to a specific database error type:

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).

Implementors

impl DatabaseError for MySqlError[src]

impl DatabaseError for PgError[src]

impl DatabaseError for SqliteError[src]

Loading content...