mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-18 00:00:15 +02:00
* Move axum crate into workspace subfolder
Over time I imagine we're gonna have other crates in this repo that
provide utilities or integrations for axum. This prepares for that by
moving the main axum crate into its own folder.
The README situation is a bit annoying because we want `./README.md`
for viewing the repo on github but `axum/README.md` for crates.io. For
now I've just copy/pasted it and added CI step to make sure they're
identical.
* update changelog link
* Add licenses to all examples
* is this how you install `diff`?
* or maybe this is how?
* fix readme links
* like this?
* fix cargo-deny step
* Try making root readme a symlink
* remove compare readme step
not needed since readme in repo root is now a symlink
* Revert "Add licenses to all examples"
This reverts commit ab321b7fb9.
39 lines
803 B
Rust
39 lines
803 B
Rust
use crate::BoxError;
|
|
use std::{error::Error as StdError, fmt};
|
|
|
|
/// Errors that can happen when using axum.
|
|
#[derive(Debug)]
|
|
pub struct Error {
|
|
inner: BoxError,
|
|
}
|
|
|
|
impl Error {
|
|
pub(crate) fn new(error: impl Into<BoxError>) -> Self {
|
|
Self {
|
|
inner: error.into(),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn downcast<T>(self) -> Result<T, Self>
|
|
where
|
|
T: StdError + 'static,
|
|
{
|
|
match self.inner.downcast::<T>() {
|
|
Ok(t) => Ok(*t),
|
|
Err(err) => Err(*err.downcast().unwrap()),
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|