Sends details on the exception which was caught (and where we stopped) to the java side.

        arg is: exception type, description, traceback object
772212
def send_caught_exception_stack(self, thread, arg, curr_frame_id):
        
        thread_id = get_thread_id(thread)
        int_cmd = InternalSendCurrExceptionTrace(thread_id, arg, curr_frame_id)
        self.post_internal_command(int_cmd, thread_id)
667970
def send_exception_to_sentry(self, exc_info):
        
        if not self.sentry_client:
            LOGGER.debug('No sentry_client, aborting')
            return

        message = dict(self.active_message)
        try:
            duration = math.ceil(time.time() - self.delivery_time) * 1000
        except TypeError:
            duration = 0
        kwargs = {'extra': {
                      'consumer_name': self.consumer_name,
                      'env': dict(os.environ),
                      'message': message},
                  'time_spent': duration}
        LOGGER.debug('Sending exception to sentry: %r', kwargs)
        self.sentry_client.captureException(exc_info, **kwargs)
802636
def annotate_exception(ex)
      new_ex = ex.exception("#{ex}; caused by #{self}")
      new_ex.set_backtrace(ex.backtrace)
      new_ex
    end
384730
def _got_request_exception(self, sender, exception, **extra):
        
        extra = self.summary_extra()
        extra['errno'] = 500
        self.summary_logger.error(str(exception), extra=extra)
        g._has_exception = True
403284
def traceback(cls, error=None, debug=True, trace=True):
        
        # TODO: if debug:
        Error.msg(error=error, debug=debug, trace=trace)
1186149
def showtraceback(self, *args, **kwargs):
        
        try:
            type, value, tb = sys.exc_info()
            sys.last_type = type
            sys.last_value = value
            sys.last_traceback = tb
            tblist = traceback.extract_tb(tb)
            del tblist[:1]
            list = traceback.format_list(tblist)
            if list:
                list.insert(0, "Traceback (most recent call last):\n")
            list[len(list):] = traceback.format_exception_only(type, value)
        finally:
            tblist = tb = None
        map(self.write, list)
740660
def log_exception(exc_info=None, stream=None):
    """"""
    exc_info = exc_info or sys.exc_info()
    stream = stream or sys.stderr
    try:
        from traceback import print_exception
        print_exception(exc_info[0], exc_info[1], exc_info[2], None, stream)
        stream.flush()
    finally:
        exc_info = None
395108
def excepthook(exc_type, exc_value, tracebackobj):
    
    separator = "-" * 80
    notice = "The following error was triggered:"

    now = datetime.now().strftime("%Y-%m-%d, %H:%M:%S")

    info = StringIO()
    traceback.print_tb(tracebackobj, None, info)
    info.seek(0)
    info = info.read()

    errmsg = f"{exc_type}\t \n{exc_value}"
    sections = [now, separator, errmsg, separator, info]
    msg = "\n".join(sections)

    print(''.join(traceback.format_tb(tracebackobj)))
    print('{0}: {1}'.format(exc_type, exc_value))

    QtWidgets.QMessageBox.warning(None, notice, traceback.format_exc())
387607
def exception_format():
    
    return "".join(traceback.format_exception(
        sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
    ))
1278310
async def handle_exception(self, error: Exception) -> Response:
        
        await got_request_exception.send(self, exception=error)

        self.log_exception(sys.exc_info())

        if self.propagate_exceptions:
            return await traceback_response()

        internal_server_error = all_http_exceptions[500]()
        handler = self._find_exception_handler(internal_server_error)

        if handler is None:
            return internal_server_error.get_response()
        else:
            return await self.finalize_request(await handler(error), from_error_handler=True)
917028
def handle_inform(self, msg):
        
        method = self._inform_handlers.get(
            msg.name, self.__class__.unhandled_inform)

        try:
            return method(self, msg)
        except Exception:
            e_type, e_value, trace = sys.exc_info()
            reason = "\n".join(traceback.format_exception(
                e_type, e_value, trace, self._tb_limit))
            self._logger.error("Inform %s FAIL: %s" % (msg.name, reason))
929781
def get_traceback(f):
  
  @functools.wraps(f)
  def wrapper(*args, **kwargs):
    try:
      return f(*args, **kwargs)
    except Exception, ex:
      ret = '#' * 60
      ret += "\nException caught:"
      ret += "\n" + '-' * 60
      ret += "\n" + traceback.format_exc()
      ret += "\n" + '-' * 60
      ret += "\n" + "#" * 60
      print sys.stderr, ret
      sys.stderr.flush()
      raise ex

  return wrapper
825060
def capture_exception(self, error=None):
        # type: (Optional[BaseException]) -> Optional[str]
        
        client = self.client
        if client is None:
            return None
        if error is None:
            exc_info = sys.exc_info()
        else:
            exc_info = exc_info_from_error(error)

        event, hint = event_from_exception(exc_info, client_options=client.options)
        try:
            return self.capture_event(event, hint=hint)
        except Exception:
            self._capture_internal_exception(sys.exc_info())

        return None
860069
void sendError(HttpResponseStatus status, Throwable ex) {
    String msg;

    if (ex instanceof InvocationTargetException) {
      msg = String.format("Exception Encountered while processing request : %s", ex.getCause().getMessage());
    } else {
      msg = String.format("Exception Encountered while processing request: %s", ex.getMessage());
    }

    // Send the status and message, followed by closing of the connection.
    responder.sendString(status, msg, new DefaultHttpHeaders().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE));
    if (bodyConsumer != null) {
      bodyConsumerError(ex);
    }
  }
1122154
def capture(self, *args, **kwargs):
        ''''''
        import traceback
        try:
            from StringIO import StringIO
        except ImportError:
            from io import StringIO
        stdout, stderr = sys.stdout, sys.stderr
        sys.stdout = out = StringIO()
        sys.stderr = err = StringIO()
        result = {
            'exception': None,
            'stderr': None,
            'stdout': None,
            'return': None
        }
        try:
            result['return'] = self.__call__(*args, **kwargs)
        except Exception:
            result['exception'] = traceback.format_exc()
        sys.stdout, sys.stderr = stdout, stderr
        result['stderr'] = err.getvalue()
        result['stdout'] = out.getvalue()
        return result
1187350
def logexception(self, logger=None):
        '''
        
        '''
        traceback.print_exc()
        if logger: 
            logger.exception('Unexpected runtime Error...')
        else:
            self.logger.exception('Unexpected runtime Error...')
374964
def handle_error(self, request, client_address):
        
        print '-'*40
        print 'Exception happened during processing of request from',
        print client_address
        import traceback
        traceback.print_exc() # XXX But this goes to stderr!
        print '-'*40