From d4eb237a8450e537cdaad2c87731383cf773150e Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 20 Sep 2024 11:50:47 +0300 Subject: Add request exception handler for gn-docs. --- gn2/wqflask/api/markdown.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'gn2/wqflask/api') diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index f9e87ee3..5dcc546d 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -243,14 +243,20 @@ def display_blog(blog_path): @gn_docs_blueprint.route("/blogs") def blogs_list(): blogs = get_blogs() - return render_template("blogs_list.html", blogs=blogs) @gn_docs_blueprint.errorhandler(requests.exceptions.HTTPError) -def page_not_found(error): - """ Return error 404 """ - return {"Reason": error.response.reason, - "error_status_code": error.response.status_code, - "error_msg": error.response.text - } +def request_exception_handler(error): + """Handler for gn-docs blueprint http errors""" + data = { + "error_reason": error.response.reason, + "error_status_code": error.response.status_code, + "error_msg": error.response.text, + } + return render_template( + "gn_docs_errors.html", + error_reason=error.response.reason, + error_msg=error.response.text, + error_status_code=error.response.status_code, + ) -- cgit v1.2.3