コード例 #1
0
ファイル: app.py プロジェクト: wtakase/indico
def handle_exception(exception):
    Logger.get('wsgi').exception(exception.message or 'WSGI Exception')
    if current_app.debug:
        raise
    return render_error(_("An unexpected error occurred."),
                        str(exception),
                        standalone=True), 500
コード例 #2
0
ファイル: base.py プロジェクト: wtakase/indico
 def _processForbidden(self, e):
     if session.user is None and not request.is_xhr and not e.response and request.blueprint != 'auth':
         return redirect_to_login(
             reason=_("Please log in to access this page."))
     message = _("Access Denied")
     explanation = get_error_description(e)
     return render_error(message, explanation)
コード例 #3
0
ファイル: base.py プロジェクト: nyimbi/indico
 def _processNotFoundError(self, e):
     if isinstance(e, NotFound):
         message = _("Page not found")  # that's a bit nicer than "404: Not Found"
         explanation = get_error_description(e)
     else:
         message = e.getMessage()
         explanation = e.getExplanation()
     return render_error(message, explanation)
コード例 #4
0
ファイル: app.py プロジェクト: luisorellanabarre/indico
def handle_404(exception):
    try:
        if re.search(r'\.py(?:/\S+)?$', request.path):
            # While not dangerous per se, we never serve *.py files as static
            raise NotFound
        try:
            return send_from_directory(current_app.config['INDICO_HTDOCS'], request.path[1:], conditional=True)
        except (UnicodeEncodeError, BadRequest):
            raise NotFound
    except NotFound:
        if exception.description == NotFound.description:
            # The default reason is too long and not localized
            description = _("The page you are looking for doesn't exist.")
        else:
            description = exception.description
        return render_error(_("Page not found"), description), 404
コード例 #5
0
ファイル: app.py プロジェクト: fph/indico
def handle_404(exception):
    try:
        if re.search(r'\.py(?:/\S+)?$', request.path):
            # While not dangerous per se, we never serve *.py files as static
            raise NotFound
        try:
            return send_from_directory(current_app.config['INDICO_HTDOCS'], request.path[1:], conditional=True)
        except UnicodeEncodeError:
            raise NotFound
    except NotFound:
        if exception.description == NotFound.description:
            # The default reason is too long and not localized
            description = _("The page you are looking for doesn't exist.")
        else:
            description = exception.description
        return render_error(_("Page not found"), description), 404
コード例 #6
0
ファイル: app.py プロジェクト: fph/indico
def handle_exception(exception):
    Logger.get('wsgi').exception(exception.message or 'WSGI Exception')
    if current_app.debug:
        raise
    return render_error(_("An unexpected error occurred."), str(exception), standalone=True), 500
コード例 #7
0
ファイル: base.py プロジェクト: wtakase/indico
 def _processBadData(self, e):
     message = _("Invalid or expired token")
     return render_error(message, e.message)
コード例 #8
0
ファイル: base.py プロジェクト: wtakase/indico
 def _processUnauthorized(self, e):
     message = _("Unauthorized")
     return render_error(message, e.description)
コード例 #9
0
ファイル: base.py プロジェクト: wtakase/indico
 def _processBadRequest(self, e):
     message = _("Bad Request")
     return render_error(message, e.description)
コード例 #10
0
 def _processBadData(self, e):
     message = _("Invalid or expired token")
     return render_error(message, e.message)
コード例 #11
0
 def _processUnauthorized(self, e):
     message = _("Unauthorized")
     return render_error(message, e.description)
コード例 #12
0
 def _processBadRequest(self, e):
     message = _("Bad Request")
     return render_error(message, e.description)
コード例 #13
0
 def _processForbidden(self, e):
     if session.user is None and not request.is_xhr and not e.response and request.blueprint != 'auth':
         return redirect_to_login(reason=_("Please log in to access this page."))
     message = _("Access Denied")
     explanation = get_error_description(e)
     return render_error(message, explanation)