Bugfix: import fails when imported script throws exception 46/170846/8
authorPaweł Stawicki <p.stawicki@samsung.com>
Thu, 22 Feb 2018 15:02:34 +0000 (16:02 +0100)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Tue, 28 May 2019 12:43:25 +0000 (14:43 +0200)
Change-Id: Ia729cc8fbb787af452e06eb95563e83bff52655b

src/batch/BatchRunner.cpp

index e0c0bf9..14fb79d 100644 (file)
@@ -799,8 +799,22 @@ void BatchExecutor::insertMethods()
                                throw std::move(error);
                        }
                        ASSERT(result);
-                       result->evaluate();
-                       it.first->second = std::move(result);
+                       CallOnExit _tmp{ [&]()
+                       {
+                               it.first->second = std::move(result);
+                       }};
+                       try
+                       {
+                               result->evaluate();
+                       } catch (ReturnValue)
+                       {
+                       } catch (BreakValue)
+                       {
+                               throw EvaluationFailure{} << "break used on global scope in file " << filename;
+                       } catch (ContinueValue)
+                       {
+                               throw EvaluationFailure{} << "continue used on global scope in file " << filename;
+                       }
                        return {};
                }, { {"filename"} } };