From 8d3c7b92324c846afc19bff9d4bf28e36b216051 Mon Sep 17 00:00:00 2001
From: Mart van Santen <mart@greenhost.nl>
Date: Wed, 29 Mar 2023 11:23:08 +0800
Subject: [PATCH] Better exception handling

---
 backend/web/login/login.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/backend/web/login/login.py b/backend/web/login/login.py
index 009781d8..424767b3 100644
--- a/backend/web/login/login.py
+++ b/backend/web/login/login.py
@@ -170,8 +170,13 @@ def login():
 
                 messages.append(message)
 
+        except ory_kratos_client.exceptions.ApiAttributeError as ex:
+            # This exception is expected when there are no messages
+            pass
         except Exception as ex:
-            current_app.logger.info("No messages in kratos flow to push to UI")
+            # An unkown exception happens, we log the error but continue as it
+            # only affects the messages part
+            current_app.logger.error("Unknown exception: " + str(ex))
 
     if identity and not refresh:
         # We are already logged in, and don't need to refresh.
-- 
GitLab