Skip to content

fix: register custom exception handlers in FastAPI app#296

Open
SouravVerma-art wants to merge 2 commits intofireform-core:mainfrom
SouravVerma-art:fix/register-exception-handlers
Open

fix: register custom exception handlers in FastAPI app#296
SouravVerma-art wants to merge 2 commits intofireform-core:mainfrom
SouravVerma-art:fix/register-exception-handlers

Conversation

@SouravVerma-art
Copy link

Summary

Custom exception handlers were defined but never registered with the FastAPI app, causing AppError to fall back to FastAPI's default handler and return 500 Internal Server Error instead of the intended status code.

Changes

  • Imported register_exception_handlers in main.py
  • Called register_exception_handlers(app) before router registration

Why

Without this fix:

  • AppError(status_code=404) incorrectly returns 500
  • API consumers receive misleading error responses
  • The structured error handling system is effectively dead code

Related

Closes #295

@Mahendrareddy2006
Copy link

Nice fix — I noticed similar behavior while testing locally where some errors were returning 500 instead of the expected status codes.

Registering the exception handlers makes sense and aligns the API responses with the intended design. I’ll test this locally to verify different error scenarios.

@SouravVerma-art
Copy link
Author

Thanks for the feedback! Yes, the issue was that the custom exception handlers were never registered, so FastAPI was falling back to the default 500 responses.
Appreciate you testing it locally, let me know if you encounter any edge cases or inconsistencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Register Custom Exception Handlers in FastAPI App

3 participants