use axol_http::{request::RequestPartsRef, response::Response};
use crate::{Error, ErrorHook, Result};
pub struct DefaultErrorHook;
#[async_trait::async_trait]
impl ErrorHook for DefaultErrorHook {
async fn handle_error<'a>(
&self,
_request: RequestPartsRef<'a>,
error: &mut Error,
) -> Result<Option<Response>> {
match &error {
Error::Internal(e) => {
log::error!("internal error: {e:#}");
}
e => {
log::debug!("returning error response: {e}");
}
}
Ok(Some(std::mem::take(error).into_response()))
}
}