axum_thiserror_tracing
Helpful IntoResponse derive macro for the thiserror crate
To derive IntoResponse, the error type must implement Debug and thiserror::Error
Bringing your own implementation of Debug allows for more flexibilty
By default, errors will have a 500 status code (INTERNAL_SERVER_ERROR) and return a plain text
response of "Something went wrong"
You can change the default text response of a 500 status code using the #[internal_text = "..."] attribute
Default behavior can be overridden on certain fields using the #[status(...)] attribute
When overridden, the server will respond with the custom status and plain text according to your Debug implementation
If you'd like a Json response, enable the crate's serde feature, and wrap the enum in Json(...)
To display the internal error with tracing, enable the crate's tracing feature
Example
use IntoResponse;
use Error;
// set the default response for StatusCode::INTERNAL_SERVER_ERROR
A working example with all the features enabled can be viewed in the repo
Contributing
All contributions are welcome. Just open a pull request in the repo.
License
This lib is licensed under the MIT license