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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -