From d092df5264f6e48f9d59650c092b8297382b1316 Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Fri, 18 Apr 2025 21:16:43 +0000
Subject: [PATCH] some built-in io module

---
 src/Interpreter/ConditionalStatementNode.hpp |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/Interpreter/ConditionalStatementNode.hpp b/src/Interpreter/ConditionalStatementNode.hpp
index efb0730..969bb8c 100644
--- a/src/Interpreter/ConditionalStatementNode.hpp
+++ b/src/Interpreter/ConditionalStatementNode.hpp
@@ -33,18 +33,22 @@
          elseBranch_(std::move(elseBranch)) {}
 
      void interpret(class Interpreter & interpreter) const override {
-         // Evaluate condition
-         auto val = condition_->evaluate(interpreter);
-         bool cond = false;
-         if (val.getType() == Symbols::Variables::Type::BOOLEAN) {
-             cond = val.get<bool>();
-        } else {
-            throw Exception("Condition did not evaluate to boolean", filename_, line_, column_);
-        }
-         // Execute appropriate branch
-         const auto & branch = cond ? thenBranch_ : elseBranch_;
-         for (const auto & stmt : branch) {
-             stmt->interpret(interpreter);
+         try {
+             auto val = condition_->evaluate(interpreter);
+             bool cond = false;
+             if (val.getType() == Symbols::Variables::Type::BOOLEAN) {
+                 cond = val.get<bool>();
+             } else {
+                 throw Exception("Condition did not evaluate to boolean", filename_, line_, column_);
+             }
+             const auto & branch = cond ? thenBranch_ : elseBranch_;
+             for (const auto & stmt : branch) {
+                 stmt->interpret(interpreter);
+             }
+         } catch (const Exception &) {
+             throw;
+         } catch (const std::exception &e) {
+             throw Exception(e.what(), filename_, line_, column_);
          }
      }
 

--
Gitblit v1.9.3