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()

View File

@@ -1,6 +1,5 @@
#include "BattleStatCalculator.hpp"
#include <Arbutils/Assert.hpp>
#include "../../Library/Exceptions/NotImplementedException.hpp"
#include "../Models/Creature.hpp"
using namespace CreatureLib;

View File

@@ -40,7 +40,7 @@ void Battle::CheckChoicesSetAndRun() {
return;
}
}
} catch (const CreatureException& e) {
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW_CREATURE("Exception during choices set validation: '" << e.what() << "'.")
@@ -81,7 +81,7 @@ void Battle::CheckChoicesSetAndRun() {
TriggerEventListener<TurnStartEvent>();
try {
TurnHandler::RunTurn(this->_currentTurnQueue);
} catch (const CreatureException& e) {
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW_CREATURE("Error during running a turn: '" << e.what() << "'.");

View File

@@ -2,7 +2,6 @@
#define CREATURELIB_SCRIPTAGGREGATOR_HPP
#include <Arbutils/Collections/List.hpp>
#include "../../Library/Exceptions/NotReachableException.hpp"
#include "Script.hpp"
#include "ScriptSet.hpp"
#include "ScriptWrapper.hpp"

View File

@@ -12,7 +12,7 @@
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
} \
} \
} catch (const CreatureException& e) { \
} catch (const ArbUt::Exception& e) { \
throw e; \
} catch (const std::exception& e) { \
THROW_CREATURE("Exception setting up script hook '" #hookName "': " << e.what()) \