Problem
ErrorHandler has a catch-all @Error(global = true, exception = Exception.class) handler that intercepts all exceptions before Micronaut's built-in handlers can run. This means framework-level HTTP exceptions (415, 405, 406, etc.) that Micronaut would handle correctly by default instead fall through to the catch-all and return 500.
We already hit this once with UnsupportedMediaException (fixed in #1051 by adding an explicit handler), but any future framework exception will have the same problem until explicitly listed.
Proposed fix
Remove handleGeneric and rely on Micronaut's built-in exception handlers, which return correct HTTP status codes for framework-level errors. To avoid leaking exception details in 500 responses (the reason the catch-all was added), configure Micronaut/Jackson to suppress exception messages from error response bodies.
Keep the application-specific handlers (ParseException → 400, IllegalArgumentException → 400, NoSuchElementException → 404) since those are not covered by Micronaut defaults.
Expected outcome
- Framework exceptions (wrong Content-Type, wrong method, not acceptable, etc.) get correct 4xx status codes without needing explicit handlers
- Unhandled exceptions still return 500 without leaking stack traces or internal messages
- No more whack-a-mole adding handlers for exceptions Micronaut already knows about
Problem
ErrorHandlerhas a catch-all@Error(global = true, exception = Exception.class)handler that intercepts all exceptions before Micronaut's built-in handlers can run. This means framework-level HTTP exceptions (415, 405, 406, etc.) that Micronaut would handle correctly by default instead fall through to the catch-all and return 500.We already hit this once with
UnsupportedMediaException(fixed in #1051 by adding an explicit handler), but any future framework exception will have the same problem until explicitly listed.Proposed fix
Remove
handleGenericand rely on Micronaut's built-in exception handlers, which return correct HTTP status codes for framework-level errors. To avoid leaking exception details in 500 responses (the reason the catch-all was added), configure Micronaut/Jackson to suppress exception messages from error response bodies.Keep the application-specific handlers (
ParseException→ 400,IllegalArgumentException→ 400,NoSuchElementException→ 404) since those are not covered by Micronaut defaults.Expected outcome