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()) {
|
while (queue->HasNext()) {
|
||||||
auto item = queue->Dequeue();
|
auto item = queue->Dequeue();
|
||||||
try {
|
try_creature(ExecuteChoice(item.get()),
|
||||||
ExecuteChoice(item.get());
|
"Executing choice failed for choice by mon on side "
|
||||||
} 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()->GetSideIndex()) << " and index "
|
||||||
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser()))
|
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser()))
|
||||||
<< " with message '" << e.what() << "'.");
|
<< " with message");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
queue->HasCompletedQueue = true;
|
queue->HasCompletedQueue = true;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +50,9 @@ void TurnHandler::ExecuteChoice(ArbUt::BorrowedPtr<BaseTurnChoice> choice) {
|
||||||
|
|
||||||
switch (choiceKind) {
|
switch (choiceKind) {
|
||||||
case TurnChoiceKind::Pass: throw NotReachableException();
|
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::Switch: return ExecuteSwitchChoice(choice.ForceAs<SwitchTurnChoice>());
|
||||||
case TurnChoiceKind::Flee: return ExecuteFleeChoice(choice.ForceAs<FleeTurnChoice>());
|
case TurnChoiceKind::Flee: return ExecuteFleeChoice(choice.ForceAs<FleeTurnChoice>());
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,12 @@ public:
|
||||||
___ss << "[" << __FILENAME__ << ":" << __LINE__ << "] " << message; \
|
___ss << "[" << __FILENAME__ << ":" << __LINE__ << "] " << message; \
|
||||||
throw CreatureException(___ss.str());
|
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
|
#endif // CREATURELIB_CREATUREEXCEPTION_HPP
|
||||||
|
|
Loading…
Reference in New Issue