glimr/http/error_handler


Error Handler

Provides default error response handlers for HTML and JSON formats. Intercepts error status codes and replaces empty responses with user-friendly error messages.

Values

pub fn default_html_responses(
  handle_request: fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body)

Default HTML Error Responses

Middleware that adds HTML error messages to error responses. Wraps the request handler and checks the response status. Success responses (2xx) pass through unchanged. Error status codes receive default HTML error pages. Can be overridden by implementing custom error handlers in your application.

pub fn default_json_responses(
  handle_request: fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body)

Default JSON Error Responses

Middleware that adds JSON error messages to error responses. Wraps the request handler and checks the response status. Success responses (2xx) pass through unchanged. Error status codes receive JSON error objects with an “error” field. Used for API routes to ensure consistent JSON error formatting.

Search Document