Is there a way to catch 500 errors in django python? -


i catch 500 exception , return http 4xx exception instead. using "except exception" catch exceptions not desired. wondering there way catch 500 errors

try:    <code> except <exception class>:    return http 404 reponse 

i searched lot couldn't figure out how same. in advance

i'm not sure returning 404 instead of 500 idea, can acheive defining custom error handler 500 errors.

in urls.py:

handler500 = 'mysite.views.my_custom_error_view' 

in views.py:

from django.http import httpresponse  def my_custom_error_view(request):     """     return 404 response instead of 500.     """     return httpresponse("error message", status_code=404) 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -