More clearer exception messages.

This commit is contained in:
2020-07-30 20:15:27 +02:00
parent 29013bb6ac
commit b3b9698831
2 changed files with 16 additions and 9 deletions

View File

@@ -14,14 +14,11 @@ void TurnHandler::RunTurn(ArbUt::BorrowedPtr<ChoiceQueue> queue) {
}
while (queue->HasNext()) {
auto item = queue->Dequeue();
try {
ExecuteChoice(item.get());
} catch (const std::exception& e) {
THROW_CREATURE("Executing choice failed for choice by mon on side "
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetSideIndex()) << " and index "
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser()))
<< " with message '" << e.what() << "'.");
}
try_creature(ExecuteChoice(item.get()),
"Executing choice failed for choice by mon on side "
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetSideIndex()) << " and index "
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser()))
<< " with message");
}
queue->HasCompletedQueue = true;
}
@@ -53,7 +50,9 @@ void TurnHandler::ExecuteChoice(ArbUt::BorrowedPtr<BaseTurnChoice> choice) {
switch (choiceKind) {
case TurnChoiceKind::Pass: throw NotReachableException();
case TurnChoiceKind::Attack: return ExecuteAttackChoice(choice.ForceAs<AttackTurnChoice>());
case TurnChoiceKind::Attack:
try_creature(return ExecuteAttackChoice(choice.ForceAs<AttackTurnChoice>()),
"Encountered exception during attack choice execution");
case TurnChoiceKind::Switch: return ExecuteSwitchChoice(choice.ForceAs<SwitchTurnChoice>());
case TurnChoiceKind::Flee: return ExecuteFleeChoice(choice.ForceAs<FleeTurnChoice>());