This example implements web::WebResponseError for a custom Error type.
Look at error_response in src/main.rs: it chooses an HTTP status and uses
HttpResponse::json to build the error body independently of the error's
Display implementation.
cd extras/json-error
cargo runThe server listens on 127.0.0.1:8000.
curl -i http://127.0.0.1:8000/GET / always returns 400 Bad Request with this JSON body:
{"error":"an example error message"}cargo test -p json-errorCovers the custom JSON error response and routing to an unknown path.