예제 #1
0
        def wrapper(*args, **kw):
            for e in list(args) + kw.values():
                if isinstance(e, Exception):
                    exception = e
                    break
            else:
                raise IndicoError(
                    'Wrong usage of jsonify_error: No error found in params')

            tb = ''
            if logging_level != 'exception' and not isinstance(
                    exception, no_tb_exceptions):
                tb = traceback.format_exc()
            logger_fn = getattr(Logger.get(logger_name), logging_level)
            logger_fn(
                logger_message
                if logger_message else 'Request finished: {} ({})\n{}'.
                format(exception.__class__.__name__, exception, tb).rstrip())

            # allow e.g. NoReportError to specify a status code without possibly
            # breaking old code that expects it with a 200 code.
            # new variable name since python2 doesn't have `nonlocal`...
            used_status = getattr(exception, 'http_status_code', status)
            if request.is_xhr or request.headers.get(
                    'Content-Type') == 'application/json':
                if log_sentry:
                    sentry_log_exception()
                return create_json_error_answer(exception, status=used_status)
            else:
                args[0]._responseUtil.status = used_status
                return f(*args, **kw)
예제 #2
0
 def _processUnexpectedError(self, e):
     """Unexpected errors"""
     self._responseUtil.redirect = None
     if config.PROPAGATE_ALL_EXCEPTIONS:
         raise
     sentry_log_exception()
     return WPUnexpectedError(self).display()
예제 #3
0
def handle_exception(exception):
    Logger.get('wsgi').exception(exception.message or 'WSGI Exception')
    if current_app.debug:
        raise
    sentry_log_exception()
    return render_error(_("An unexpected error occurred."),
                        str(exception),
                        standalone=True), 500
예제 #4
0
def handle_exception(exc, message=None):
    Logger.get('flask').exception(to_unicode(exc.message) or 'Uncaught Exception')
    if not current_app.debug or request.is_xhr or request.is_json:
        sentry_log_exception()
        if message is None:
            message = '{}: {}'.format(type(exc).__name__, to_unicode(exc.message))
        return render_error(exc, _('Something went wrong'), message, 500)
    # Let the exception propagate to middleware /the webserver.
    # This triggers the Flask debugger in development and sentry
    # logging (if enabled) (via got_request_exception).
    raise
예제 #5
0
파일: errors.py 프로젝트: bkolobara/indico
def handle_exception(exc, message=None):
    Logger.get('flask').exception(to_unicode(exc.message) or 'Uncaught Exception')
    if not current_app.debug or request.is_xhr or request.is_json:
        sentry_log_exception()
        if message is None:
            message = '{}: {}'.format(type(exc).__name__, to_unicode(exc.message))
        return render_error(exc, _('Something went wrong'), message, 500)
    # Let the exception propagate to middleware /the webserver.
    # This triggers the Flask debugger in development and sentry
    # logging (if enabled) (via got_request_exception).
    raise
예제 #6
0
def handle_exception(exc, message=None):
    Logger.get('flask').exception(str(exc) or 'Uncaught Exception')
    if not current_app.debug or request.is_xhr or request.is_json:
        sentry_log_exception()
        if message is None:
            message = '{}: {}'.format(type(exc).__name__, str(exc))
        if os.environ.get('INDICO_DEV_SERVER') == '1':
            # If we are in the dev server, we always want to see a traceback on the
            # console, even if this was an API request.
            traceback.print_exc()
        return render_error(exc, _('Something went wrong'), message, 500)
    # Let the exception propagate to middleware /the webserver.
    # This triggers the Flask debugger in development and sentry
    # logging (if enabled) (via got_request_exception).
    raise