Core Concepts
Exception Filters
Exception filters catch errors thrown during request processing and translate them to HTTP responses. Learn the ExceptionFilterable interface and built-in exceptions.
Exception Filters
Exception filters catch errors that propagate through the pipeline and translate them into structured HTTP responses. By default, unhandled panics produce a 500 Internal Server Error.
The ExceptionFilterable Interface
Built-in Exception Types
Ginject's exception package provides typed HTTP errors. Throw them with panic:
Writing a Custom Filter
Custom Error Response Shape
Applying Exception Filters
Exception Filter Scope
Multiple filters can be active for a request. The most specific filter (handler-level > controller-level > module-level > global) handles the exception.
Working with the Exception Type
Access the fields in Catch: