Handler for unhandled exceptions that will write to the logs
434066
def handle_unhandled_exception(exc_type, exc_value, exc_traceback):
    """"""
    if issubclass(exc_type, KeyboardInterrupt):
        # call the default excepthook saved at __excepthook__
        sys.__excepthook__(exc_type, exc_value, exc_traceback)
        return
    logger = logging.getLogger(__name__) # type: ignore
    logger.critical("Unhandled exception", exc_info=(exc_type, exc_value, exc_traceback))
1355471
def example_exc_handler(tries_remaining, exception, delay):
    
    print >> sys.stderr, "Caught '%s', %d tries remaining, sleeping for %s seconds" % (
        exception, tries_remaining, delay)
225207
def _onError(self, error):
        
        self.stop()
        self._logModule.err(
            error,
            "Unhandled error logging exception to %s" % (self.airbrakeURL,))
        self.start()
1245974
def send_exception(self):
        """"""
        self.compiler.reset()

        exc = traceback.format_exc()
        self.writer.write(exc.encode('utf8'))

        yield from self.writer.drain()
1090948
@Override
	public void onUncaughtException(Throwable throwable) {
		for (ErrorHandler handler : this.errorHandlers) {
			if (handler.handle(throwable)) {
				return;
			}
		}
		this.defaultHandler.handle(throwable);
	}
1042471
def log_exception(self, exc_info):
        """"""
        dsn = self.config.get("SENTRY_DSN")
        if not dsn:
            super().log_exception(exc_info)
681521
public static void errorForException(Logger log, Throwable throwable,
            String methodName) {
        log.error(buildMethodLogString(methodName), throwable);
    }
1224785
def log_errors(self):
        
        for result in self._stored.values():
            failure = result.original_failure()
            if failure is not None:
                log.err(failure, "Unhandled error in stashed EventualResult:")
749120
def handling_exceptions(self):
        """"""
        try:
            if self.using_jobs:
                with handling_broken_process_pool():
                    yield
            else:
                yield
        except SystemExit as err:
            self.register_error(err.code)
        except BaseException as err:
            if isinstance(err, CoconutException):
                logger.display_exc()
            elif not isinstance(err, KeyboardInterrupt):
                traceback.print_exc()
                printerr(report_this_text)
            self.register_error(errmsg=err.__class__.__name__)
1280410
def formatException(self, exc_info, record=None):
        """"""
        if not record:
            return logging.Formatter.formatException(self, exc_info)

        stringbuffer = cStringIO.StringIO()
        traceback.print_exception(exc_info[0], exc_info[1], exc_info[2],
                                  None, stringbuffer)
        lines = stringbuffer.getvalue().split('\n')
        stringbuffer.close()

        if CONF.logging_exception_prefix.find('%(asctime)') != -1:
            record.asctime = self.formatTime(record, self.datefmt)

        formatted_lines = []
        for line in lines:
            pl = CONF.logging_exception_prefix % record.__dict__
            fl = '%s%s' % (pl, line)
            formatted_lines.append(fl)
        return '\n'.join(formatted_lines)
1255833
def _log_future_exception(future, logger):
    """"""

    if not future.done():
        return

    try:
        future.result()
    except:  #pylint:disable=bare-except;This is a background logging helper
        logger.warning("Exception in ignored future: %s", future, exc_info=True)
682540
def exception_logger(exc_type, exc_value, exc_traceback):
    """"""
    if not issubclass(exc_type, KeyboardInterrupt):  # do not log Ctrl-C
        _log.critical(
            "Uncaught exception:",
            exc_info=(exc_type, exc_value, exc_traceback)
        )
    sys.__excepthook__(exc_type, exc_value, exc_traceback)
78759
private void handleException(final Throwable e)
    {
        if ( errorListeners.size() == 0 )
        {
            LOG.error("", e);
        }
        else
        {
            errorListeners.forEach(new Function<UnhandledErrorListener, Void>()
            {
                @Override
                public Void apply(UnhandledErrorListener listener)
                {
                    try
                    {
                        listener.unhandledError("", e);
                    }
                    catch ( Exception e )
                    {
                        ThreadUtils.checkInterrupted(e);
                        LOG.error("Exception handling exception", e);
                    }
                    return null;
                }
            });
        }
    }
521210
def exception_log_and_respond(exception, logger, message, status_code):
    """"""
    logger.error(message, exc_info=True)
    return make_response(
        message,
        status_code,
        dict(exception_type=type(exception).__name__, exception_message=str(exception)),
    )
1106291
public static void logUncaughtExceptions(Logging logger) {
    try {
      Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.exception(e));
    }
    catch(SecurityException e) {
      logger.warning("Could not set the Default Uncaught Exception Handler", e);
    }
  }
463318
function listenUnhandledErrors(logger) {
  if (logger === void 0) {
    logger = new Logger('nightingale.listenUnhandledErrors', 'listenUnhandledErrors');
  }

  process.on('uncaughtException', function (err) {
    return logger.error('uncaughtException', {
      err: err
    });
  });
  process.on('unhandledRejection', function (err) {
    return logger.error('unhandledRejection', {
      err: err
    });
  });
}
1286732
@Override
	public void handle(final T throwable, final boolean throwRuntimeException) {
		this.logger.error(throwable);
		if (throwRuntimeException) {
			if (throwable instanceof RuntimeException) {
				throw (RuntimeException) throwable;
			}
			throw new RuntimeException(throwable);
		}
	}