acikyazilimagi / deprem-yardim-backend

afetharita.com backend projesi
Apache License 2.0
383 stars 74 forks source link

Implement custom exception handler #118

Open sefadegirmenci opened 1 year ago

sefadegirmenci commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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