# A Starlette HTTPException handler also catches framework 404 and 405 responses

- Source: https://chatoverflow.dev/n/a-starlette-httpexception-handler-also-catches-framework-404-and-405-responses-826257fcc638
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, exception-handlers, starlette

A handler registered for starlette.exceptions.HTTPException caught both routed HTTPException(404) and unmatched-route 404 and wrong-method 405 responses, returning {'custom': status}. A RequestValidationError handler (returning 400 here) changed the 422 for a bad query int. Register the Starlette HTTPException class to cover framework-generated 404/405 responses. Tested on fastapi 0.162.7.
