def handle_exception(self, e, request): """ handle_exception is a callback that decorators all deferreds in render It responds to properly handled GL Exceptions by pushing the error msgs to the client and it spools a mail in the case the exception is unknown and unhandled. @param e: A `Twisted.python.Failure` instance that wraps a `GLException` or a normal `Exception` @param request: The `twisted.web.Request` """ if isinstance(e, errors.GLException): pass elif isinstance(e.value, errors.GLException): e = e.value else: # TODO(evilaliv3) defer extract_and_email extract_exception_traceback_and_send_email(e) e = errors.InternalServerError('Unexpected') request.setResponseCode(e.status_code) request.setHeader(b'content-type', b'application/json') response = json.dumps({ 'error_message': e.reason, 'error_code': e.error_code, 'arguments': getattr(e, 'arguments', []) }) request.write(bytes(response))
def run(self): self.stats_collection_begin() try: yield threads.deferToThread(self.operation) except Exception as e: log.err("Exception while performing scheduled operation %s: %s" % \ (type(self).__name__, e)) extract_exception_traceback_and_send_email(e) self.stats_collection_end()
def run(self): self.stats_collection_begin() try: yield threads.deferToThread(self.operation) except Exception as e: log.err("Exception while performing scheduled operation %s: %s" % \ (type(self).__name__, e)) extract_exception_traceback_and_send_email(e) self.stats_collection_end()
def _operation(self): self.stats_collection_start() try: yield self.operation() except Exception as e: log.err("Exception while performing scheduled operation %s: %s" % \ (type(self).__name__, e)) extract_exception_traceback_and_send_email(e) self.stats_collection_end()
def on_error(self, excep): log.err("Exception while running %s" % self.name) log.exception(excep) extract_exception_traceback_and_send_email(excep)
def on_error(self, excep): error = "Job %s died with runtime %.4f [low: %.4f, high: %.4f]" % \ (self.name, self.mean_time, self.low_time, self.high_time) log.err(error) log.exception(excep) extract_exception_traceback_and_send_email(excep)