def _handle_request_exception(self, e): if isinstance(e, Failure): exc_type = e.type exc_value = e.value exc_tb = e.getTracebackObject() e = e.value else: exc_type, exc_value, exc_tb = sys.exc_info() if isinstance(e, (HTTPError, HTTPAuthenticationRequired)): if GLSetting.http_log and e.log_message: string_format = "%d %s: " + e.log_message args = [e.status_code, self._request_summary()] + list(e.args) msg = lambda *args: string_format % args log.msg(msg(*args)) if e.status_code not in httplib.responses: log.msg("Bad HTTP status code: %d" % e.status_code) return self.send_error(500, exception=e) else: return self.send_error(e.status_code, exception=e) else: log.err("Uncaught exception %s %s %s" % (exc_type, exc_value, exc_tb)) if GLSetting.http_log: log.msg(e) mail_exception(exc_type, exc_value, exc_tb) return self.send_error(500, exception=e)
def _handle_request_exception(self, e): # sys.exc_info() does not always work at this stage if isinstance(e, Failure): exc_type = e.type exc_value = e.value exc_tb = e.getTracebackObject() e = e.value else: exc_type, exc_value, exc_tb = sys.exc_info() if isinstance(e, (HTTPError, HTTPAuthenticationRequired)): if GLSetting.http_log and e.log_message: string_format = "%d %s: " + e.log_message args = [e.status_code, self._request_summary()] + list(e.args) msg = lambda *args: string_format % args log.msg(msg(*args)) if e.status_code not in httplib.responses: log.msg("Bad HTTP status code: %d" % e.status_code) return self.send_error(500, exception=e) else: return self.send_error(e.status_code, exception=e) else: log.err("Uncaught exception %s %s %s" % (exc_type, exc_value, exc_tb)) if GLSetting.http_log: log.msg(e) mail_exception(exc_type, exc_value, exc_tb) return self.send_error(500, exception=e)
def _operation(self): try: self.operation() except Exception as e: log.err("Exception while performin scheduled operation %s: %s" % \ (type(self).__name__, e)) try: if isinstance(e, Failure): exc_type = e.type exc_value = e.value exc_tb = e.getTracebackObject() else: exc_type, exc_value, exc_tb = sys.exc_info() mail_exception(exc_type, exc_value, exc_tb) except Exception: pass
def _operation(self): try: self.operation() except Exception as e: log.err("Exception while performin scheduled operation %s: %s" % \ (type(self).__name__, e)) try: if isinstance(e, Failure): exc_type = e.type exc_value = e.value exc_tb = e.getTracebackObject() else: exc_type, exc_value, exc_tb = sys.exc_info() mail_exception(exc_type, exc_value, exc_tb) except Exception: pass