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
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)
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)
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
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
def _processBadData(self, e): message = _("Invalid or expired token") return render_error(message, e.message)
def _processUnauthorized(self, e): message = _("Unauthorized") return render_error(message, e.description)
def _processBadRequest(self, e): message = _("Bad Request") return render_error(message, e.description)
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)