Opened 11 years ago

Closed 11 years ago

#21536 closed Cleanup/optimization (worksforme)

the handler swallows exception

Reported by: wuhaochi@… Owned by: nobody
Component: Core (Other) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

line /Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/handlers/base.py : 197.
the code is this:

        except: # Handle everything else.                                                                                                                                         
            # Get the exception info now, in case another exception is thrown later.                                                                                              
            signals.got_request_exception.send(sender=self.__class__, request=request)                                                                                            
            response = self.handle_uncaught_exception(request, resolver, sys.exc_info())     


And this haunted me quite a while when I just made a syntax mistake in my view function. Since I was reported "Server Error 500 27"
Internal Server error. But why?
When I add this block, I find the answer of my error.

      except Exception as e:                                                                                                                                                    
            import traceback                                                                                                                                                      
            traceback.print_exc(e)                                                                                                                                                
                                                                                                                                                                                  
        except: # Handle everything else.                                                                                                                                         
            # Get the exception info now, in case another exception is thrown later.                                                                                              
            signals.got_request_exception.send(sender=self.__class__, request=request)                                                                                            
            response = self.handle_uncaught_exception(request, resolver, sys.exc_info())                                                                                         


Change History (1)

comment:1 by Tim Graham, 11 years ago

Resolution: worksforme
Status: newclosed

It looks to me like you're requesting us to add logging for errors, however, if you have logging properly setup, handle_uncaught_exception() should log the error. If DEBUG=True you should get a colorful error page.

Note: See TracTickets for help on using tickets.
Back to Top