From c593904a19cd93301d3a962a5a0b21894de1e6ae Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 25 May 2024 15:04:26 +0200 Subject: [PATCH] feat: Enhance error handling responses with correct status codes Updated error handlers for 404, 400, 429, and 500 HTTP error responses to explicitly return the corresponding status codes along with the error templates. This change ensures that responses not only serve the correct error pages but also reflect the appropriate HTTP status codes, improving compliance with HTTP standards and enhancing the clarity of the server's response to clients. This adjustment aids in proper error diagnostics and handling by both the client applications and search engines, potentially influencing SEO and user experience positively by ensuring that web crawlers correctly interpret the nature of the errors. Resolves issues related to ambiguous HTTP status codes in error responses. --- src/structables/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structables/main.py b/src/structables/main.py index b9b0ab6..5c62f39 100644 --- a/src/structables/main.py +++ b/src/structables/main.py @@ -1195,22 +1195,22 @@ def privacypolicy(): @app.errorhandler(404) def not_found(e): - return render_template("404.html") + return render_template("404.html"), 404 @app.errorhandler(400) def bad_request(e): - return render_template("400.html") + return render_template("400.html"), 400 @app.errorhandler(429) def too_many_requests(e): - return render_template("429.html") + return render_template("429.html"), 429 @app.errorhandler(500) def internal_server_error(e): - return render_template("500.html") + return render_template("500.html"), 500 def main():