rusty-gasket-macros
Procedural macros for the Rusty Gasket framework. Currently provides #[derive(ApiError)] for generating ApiError trait implementations and IntoResponse conversions from annotated enum variants.
Usage
use ApiError;
Attributes
Each enum variant must be annotated with #[api_error(...)]:
| Attribute | Required | Description |
|---|---|---|
code |
yes | Machine-readable error code string (e.g., "NOT_FOUND") |
status |
yes | HTTP status code (e.g., 404) |
expose |
no | Whether to expose the error message to the client. Defaults to true for 4xx, false for 5xx |
The derive macro generates:
- An
ApiErrortrait implementation witherror_code(),status_code(), andexpose_details() - An
IntoResponseimplementation that produces standardized JSON error bodies viaerror_into_response()
Documentation
See the top-level README and the rusty-gasket crate's error module for the full error handling architecture.