Skip to content

Commit

Permalink
Merge pull request #4372 from horazont/feature/r2d2-error-conversion
Browse files Browse the repository at this point in the history
Add From impls to convert other error types to diesel::r2d2::Error
  • Loading branch information
weiznich committed Dec 5, 2024
2 parents 2303c0b + fc09bb3 commit 233f814
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions diesel/src/r2d2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ impl fmt::Display for Error {

impl ::std::error::Error for Error {}

impl From<crate::result::Error> for Error {
fn from(other: crate::result::Error) -> Self {
Self::QueryError(other)
}
}

impl From<ConnectionError> for Error {
fn from(other: ConnectionError) -> Self {
Self::ConnectionError(other)
}
}

/// A trait indicating a connection could be used inside a r2d2 pool
pub trait R2D2Connection: Connection {
/// Check if a connection is still valid
Expand Down

0 comments on commit 233f814

Please sign in to comment.