Rework exceptions.
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-08-15 16:34:52 +02:00
parent c921d3127b
commit 93a763ab78
12 changed files with 29 additions and 55 deletions

View File

@@ -1,7 +1,6 @@
#include "TurnHandler.hpp"
#include <Arbutils/Assert.hpp>
#include <unordered_set>
#include "../../Library/Exceptions/NotImplementedException.hpp"
#include "../EventHooks/EventDataClasses.hpp"
#include "../History/HistoryElements/AttackUseHistory.hpp"
#include "../ScriptHandling/ScriptMacros.hpp"
@@ -58,14 +57,14 @@ void TurnHandler::ExecuteChoice(ArbUt::BorrowedPtr<BaseTurnChoice> choice) {
}
switch (choiceKind) {
case TurnChoiceKind::Pass: throw NotReachableException();
case TurnChoiceKind::Pass: return;
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>());
case TurnChoiceKind::Item: throw NotImplementedException();
case TurnChoiceKind::Item: NOT_IMPLEMENTED;
}
}
@@ -201,7 +200,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
if (hasSecondaryEffect) {
HOOK(OnSecondaryEffect, user, attack, target.GetRaw(), hitIndex);
}
} catch (const CreatureException& e) {
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW_CREATURE("Exception during status attack effect handling: " << e.what() << ".");
@@ -233,7 +232,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
if (hasSecondaryEffect) {
HOOK(OnSecondaryEffect, user, attack, target.GetRaw(), hitIndex);
}
} catch (const CreatureException& e) {
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW_CREATURE("Exception during offensive attack secondary effect handling: " << e.what()