Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Implement custom exception handler #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sefadegirmenci
Copy link
Contributor

@sefadegirmenci sefadegirmenci commented Feb 8, 2023

Description

This pull request adds a custom exception handler to the Django project. The handler provides a consistent way of handling exceptions and gives better control over the handling process. If an exception is not handled, the handler will now return a 500 response code without any garbage-like error messages.

Related Issue

#109

Motivation and Context

I did not observe 500 code as mentioned in the issue, however, it would be appropriate to have an exception handler. While we currently only raise Validation Errors in the codebase, it is possible that we will need to add custom errors in the future. Having a handler in place will allow us to customize the error messages and response codes for these errors.

Screenshots (if appropriate):

Screen Shot 2023-02-08 at 14 37 43

@yamac-kurtulus
Copy link
Contributor

yamac-kurtulus commented Feb 8, 2023

Did you try this with the HTML API? it feels like it does not work as intended (i.e. in HTML API) but I cannot be sure. I think the DRF's exception handler is more than capable.

@sefadegirmenci
Copy link
Contributor Author

It seems to be fixed with this exception handler:

Before:
Screen Shot 2023-02-08 at 15 11 49

Now:
Screen Shot 2023-02-08 at 15 11 32

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants