More clearer exception messages.
This commit is contained in:
parent
29013bb6ac
commit
b3b9698831
|
@ -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 "
|
||||
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 '" << e.what() << "'.");
|
||||
}
|
||||
<< " 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>());
|
||||
|
||||
|
|
|
@ -17,4 +17,12 @@ public:
|
|||
___ss << "[" << __FILENAME__ << ":" << __LINE__ << "] " << message; \
|
||||
throw CreatureException(___ss.str());
|
||||
|
||||
#define try_creature(data, msg) \
|
||||
try { \
|
||||
data; \
|
||||
} catch (const CreatureException& e) { \
|
||||
throw e; \
|
||||
} catch (const std::exception& e) { \
|
||||
THROW_CREATURE(msg << ": '" << e.what() << "'."); \
|
||||
}
|
||||
#endif // CREATURELIB_CREATUREEXCEPTION_HPP
|
||||
|
|
Loading…
Reference in New Issue