From 06de6a3a5b40a42cfc894f87b86a46ee09aa6bba Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Tue, 4 Jul 2023 15:44:27 +0200
Subject: [PATCH] Debug: Add exeception.

---
 src/View/Debug/Window.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/View/Debug/Window.py b/src/View/Debug/Window.py
index dd26d91e..5fad77df 100644
--- a/src/View/Debug/Window.py
+++ b/src/View/Debug/Window.py
@@ -70,12 +70,14 @@ class ReplWindow(ASubMainWindow, ListedSubWindow):
         self.set_line_edit_text("lineEdit", "")
         self._history_ind = 0
 
-        code = "self.__debug_exec_result__ = " + code
+        rich_code = "self.__debug_exec_result__ = " + code
         print(f"[DEBUG] ! {code}")
-        value = exec(code)
-        value = self.__debug_exec_result__
+        try:
+            value = exec(rich_code)
+            value = self.__debug_exec_result__
+        except Exception as e:
+            value = f"<font color=\"red\">" + str(e) + "</font>"
 
         msg = f"<font color=\"grey\"> # " + code + " #</font>"
         self.find(QTextEdit, "textEdit").append(msg)
-
         self.find(QTextEdit, "textEdit").append(str(value))
-- 
GitLab