Installation:
toml
[dependencies]
axum_error_macro = { version = "0.1.4" }
Simple example
```rust use axumerrormacro::IntoResponse; use axum::response::Response;
enum Error { #[error(code = 500, msg = "Internal Server Error!!!")] InternalServerError,
#[error(code = 400, msg = "Bad Request!!!")] BadRequest,
#[error(code = 404, msg = "User by {} id was not found")] UserByIdNotFound(u32),
#[error(code = 404, msg = "User by {} username with {} role was not found")] UserByUsernameAndRoleNotFound(String, String),
#[error(code = 404, msg = "User {:?} was not found")] UserNotFound(User) }
struct User { username: String }
fn servererrorhandler() -> Response { return Error::InternalServerError.into_response(); }
fn userbyidhandler() -> Response { return Error::UserByIdNotFound(1).intoresponse(); }
fn userbyusernameandrolehandler() -> Response { return Error::UserByUsernameAndRoleNotFound("Bebra".into(), "ADMIN".into()).intoresponse(); }
fn userhandler() -> Response { let user = User { username: "Bebra".into() }; return Error::UserNotFound(user).intoresponse(); } ```