2021-08-21 15:01:30 +02:00
|
|
|
use crate::BoxError;
|
2021-08-07 19:56:44 +02:00
|
|
|
use std::{error::Error as StdError, fmt};
|
|
|
|
|
|
|
|
|
|
/// Errors that can happen when using axum.
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct Error {
|
|
|
|
|
inner: BoxError,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Error {
|
2021-11-30 14:46:13 +01:00
|
|
|
/// Create a new `Error` from a boxable error.
|
|
|
|
|
pub fn new(error: impl Into<BoxError>) -> Self {
|
2021-08-07 19:56:44 +02:00
|
|
|
Self {
|
|
|
|
|
inner: error.into(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for Error {
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
|
self.inner.fmt(f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl StdError for Error {
|
|
|
|
|
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
|
|
|
|
Some(&*self.inner)
|
|
|
|
|
}
|
|
|
|
|
}
|