Skip to content

Commit

Permalink
Set the verification result to not Ok, when the arbitrator catched an…
Browse files Browse the repository at this point in the history
… exception
  • Loading branch information
orzechow committed Nov 19, 2024
1 parent b9e2d6f commit d367189
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/arbitration_graphs/internal/arbitrator_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ SubCommandT Arbitrator<CommandT, SubCommandT, VerifierT, VerificationResultT>::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;
}
Expand Down
3 changes: 2 additions & 1 deletion test/handle_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d367189

Please sign in to comment.