kyoto7250 dd545441d3
introduce rustfmt (#919)
* introduce rustfmt

* Cargofmt on all sea-orm crates & examples

* Revert testing script

* cargo fmt --manifest-path sea-orm-rocket/Cargo.toml --all

* add a script for formatting

* add nightly component for formatting

* set timeout and manual nightly install  in github action

* add flag for manifest-path

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2022-08-01 18:30:43 +08:00

40 lines
1.1 KiB
Rust

use std::fmt;
/// A general error type for use by [`Pool`](crate::Pool#implementing)
/// implementors and returned by the [`Connection`](crate::Connection) request
/// guard.
#[derive(Debug)]
pub enum Error<A, B = A> {
/// An error that occured during database/pool initialization.
Init(A),
/// An error that ocurred while retrieving a connection from the pool.
Get(B),
/// A [`Figment`](crate::figment::Figment) configuration error.
Config(crate::figment::Error),
}
impl<A: fmt::Display, B: fmt::Display> fmt::Display for Error<A, B> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Init(e) => write!(f, "failed to initialize database: {}", e),
Error::Get(e) => write!(f, "failed to get db connection: {}", e),
Error::Config(e) => write!(f, "bad configuration: {}", e),
}
}
}
impl<A, B> std::error::Error for Error<A, B>
where
A: fmt::Debug + fmt::Display,
B: fmt::Debug + fmt::Display,
{
}
impl<A, B> From<crate::figment::Error> for Error<A, B> {
fn from(e: crate::figment::Error) -> Self {
Self::Config(e)
}
}