From 8e89a87636fc99053dedb55c3daee85ede4a2953 Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Wed, 23 Nov 2022 17:31:51 +0800 Subject: [PATCH] Wrap all exception with ProblemDetail in json object Issue-ID: INF-376 Signed-off-by: Bin Yang Change-Id: I3f8ed081c5896eedda311f00e5a57e7ccf461a56 --- o2common/views/route_exception.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/o2common/views/route_exception.py b/o2common/views/route_exception.py index 07a60a3..ccb439b 100644 --- a/o2common/views/route_exception.py +++ b/o2common/views/route_exception.py @@ -85,3 +85,9 @@ def configure_exception(app): '''Return a custom message and 500 status code''' problem = ProblemDetails(500, "Internal Server Error") return problem.serialize(), 500 + + @app.errorhandler(Exception) + def handle_general_exception(error): + '''Return a custom message and 500 status code''' + problem = ProblemDetails(500, "Internal Server Error") + return problem.serialize(), 500 -- 2.16.6