mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Fix error_handler
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
from flask import Blueprint
 | 
			
		||||
from werkzeug.exceptions import HTTPException
 | 
			
		||||
from .handlers import generic_error_handler
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bp = Blueprint('errors', __name__)
 | 
			
		||||
from . import handlers
 | 
			
		||||
def init_app(app):
 | 
			
		||||
    app.register_error_handler(HTTPException, generic_error_handler)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,6 @@
 | 
			
		||||
from flask import render_template, request
 | 
			
		||||
from werkzeug.exceptions import HTTPException
 | 
			
		||||
from . import bp
 | 
			
		||||
from flask import render_template
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.errorhandler(HTTPException)
 | 
			
		||||
def generic_error_handler(e):
 | 
			
		||||
    if (request.accept_mimetypes.accept_json
 | 
			
		||||
            and not request.accept_mimetypes.accept_html):
 | 
			
		||||
        return {'errors': {'message': e.description}}, e.code
 | 
			
		||||
    print('test')
 | 
			
		||||
    return render_template('errors/error.html.j2', error=e), e.code
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user