From d36718937f527924569b18a448e8f6559b45650c Mon Sep 17 00:00:00 2001 From: Piotr Spieker Date: Tue, 19 Nov 2024 23:39:21 +0100 Subject: [PATCH] Set the verification result to not Ok, when the arbitrator catched an exception --- include/arbitration_graphs/internal/arbitrator_impl.hpp | 2 +- test/handle_exceptions.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/arbitration_graphs/internal/arbitrator_impl.hpp b/include/arbitration_graphs/internal/arbitrator_impl.hpp index a3147359..deb73023 100644 --- a/include/arbitration_graphs/internal/arbitrator_impl.hpp +++ b/include/arbitration_graphs/internal/arbitrator_impl.hpp @@ -115,7 +115,7 @@ SubCommandT Arbitrator::g command = getAndVerifyCommand(bestOption, time); } catch (const std::exception& e) { VLOG(1) << bestOption->behavior_->name_ << " threw an exception during getAndVerifyCommand(): " << e.what(); - bestOption->verificationResult_.reset(); + bestOption->verificationResult_.cache(time, VerificationResultT{false}); bestOption->behavior_->loseControl(time); continue; } diff --git a/test/handle_exceptions.cpp b/test/handle_exceptions.cpp index 2462f838..10afa598 100644 --- a/test/handle_exceptions.cpp +++ b/test/handle_exceptions.cpp @@ -33,9 +33,10 @@ TEST_F(ExceptionHandlingTest, HandleException) { // Since the high priority behavior is broken, we should get the low priority behavior as fallback EXPECT_EQ("LowPriority", testPriorityArbitrator.getCommand(time)); - EXPECT_FALSE(testPriorityArbitrator.options().at(0)->verificationResult_.cached(time)); + ASSERT_TRUE(testPriorityArbitrator.options().at(0)->verificationResult_.cached(time)); ASSERT_TRUE(testPriorityArbitrator.options().at(1)->verificationResult_.cached(time)); + EXPECT_FALSE(testPriorityArbitrator.options().at(0)->verificationResult_.cached(time)->isOk()); EXPECT_TRUE(testPriorityArbitrator.options().at(1)->verificationResult_.cached(time)->isOk()); testPriorityArbitrator.loseControl(time);