deprem-yardim-backend icon indicating copy to clipboard operation
deprem-yardim-backend copied to clipboard

Implement custom exception handler

Open sefadegirmenci opened this issue 2 years ago • 2 comments

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

sefadegirmenci avatar Feb 08 '23 11:02 sefadegirmenci

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.

yamac-kurtulus avatar Feb 08 '23 12:02 yamac-kurtulus

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

sefadegirmenci avatar Feb 08 '23 12:02 sefadegirmenci