Use something like:

``` use axum::errorhandling::HandleErrorLayer; use axum::Router; use hmacpredicate::HmacQueryParamValidator; use reqwest::StatusCode; use tower::{BoxError, ServiceBuilder};

[tokio::main]

async fn main() { let predicate: HmacQueryParamValidator = HmacQueryParamValidator { key: APISECRET.tostring(), };

let builder = ServiceBuilder::new()
    .layer(HandleErrorLayer::new(handle_error))
    .filter(predicate);

let app = Router::new()
    .route("/", get(handler))
    .layer(builder);

}

async fn handleerror(err: BoxError) -> (StatusCode, String) { ( StatusCode::INTERNALSERVER_ERROR, format!("Unhandled internal error: {}", err), ) } ```