Update to latest Arbutils, include stacktrace.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
46ab060b99
commit
c921d3127b
|
@ -22,7 +22,7 @@ export bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Cre
|
||||||
}
|
}
|
||||||
export uint8_t CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
|
export uint8_t CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
|
||||||
export const Creature* const* CreatureLib_ExecutingAttack_GetTargets(ExecutingAttack* p) {
|
export const Creature* const* CreatureLib_ExecutingAttack_GetTargets(ExecutingAttack* p) {
|
||||||
return reinterpret_cast<const Creature* const*>(p->GetTargets());
|
return reinterpret_cast<const Creature* const*>(p->GetTargets().RawData());
|
||||||
}
|
}
|
||||||
|
|
||||||
export Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser().GetRaw(); }
|
export Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser().GetRaw(); }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef CREATURELIB_CORE_HPP
|
#ifndef CREATURELIB_CORE_HPP
|
||||||
#define CREATURELIB_CORE_HPP
|
#define CREATURELIB_CORE_HPP
|
||||||
|
|
||||||
|
#include <Arbutils/Exception.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -14,6 +15,12 @@ class ExceptionHandler {
|
||||||
static std::string _creatureLibLastException;
|
static std::string _creatureLibLastException;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static void SetLastException(std::string function, const ArbUt::Exception& e) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "[" << function << "] " << e.what() << std::endl;
|
||||||
|
ss << e.GetStacktrace();
|
||||||
|
_creatureLibLastException = ss.str();
|
||||||
|
}
|
||||||
static void SetLastException(std::string function, const std::exception& e) {
|
static void SetLastException(std::string function, const std::exception& e) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "[" << function << "] " << e.what();
|
ss << "[" << function << "] " << e.what();
|
||||||
|
@ -26,6 +33,9 @@ public:
|
||||||
try { \
|
try { \
|
||||||
data; \
|
data; \
|
||||||
return 0; \
|
return 0; \
|
||||||
|
} catch (const ArbUt::Exception& e) { \
|
||||||
|
ExceptionHandler::SetLastException(__FUNCTION__, e); \
|
||||||
|
return CreatureLibException; \
|
||||||
} catch (const std::exception& e) { \
|
} catch (const std::exception& e) { \
|
||||||
ExceptionHandler::SetLastException(__FUNCTION__, e); \
|
ExceptionHandler::SetLastException(__FUNCTION__, e); \
|
||||||
return CreatureLibException; \
|
return CreatureLibException; \
|
||||||
|
|
|
@ -122,24 +122,24 @@ void TurnHandler::ExecuteAttackChoice(const ArbUt::BorrowedPtr<AttackTurnChoice>
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::BorrowedPtr<Creature>& target) {
|
void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::BorrowedPtr<Creature>& target) {
|
||||||
auto user = attack->GetUser();
|
AssertNotNull(attack)
|
||||||
|
auto& user = attack->GetUser();
|
||||||
AssertNotNull(user)
|
AssertNotNull(user)
|
||||||
AssertNotNull(target)
|
AssertNotNull(target)
|
||||||
if (user->GetBattle()->HasEnded())
|
auto& battle = user->GetBattle();
|
||||||
|
AssertNotNull(battle)
|
||||||
|
if (battle->HasEnded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& targetSource = target;
|
|
||||||
auto userSource = attack;
|
|
||||||
|
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
HOOK(FailIncomingAttack, targetSource, attack, target.GetRaw(), &fail);
|
HOOK(FailIncomingAttack, target, attack, target.GetRaw(), &fail);
|
||||||
if (fail) {
|
if (fail) {
|
||||||
// TODO: Fail handling.
|
// TODO: Fail handling.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invulnerable = false;
|
bool invulnerable = false;
|
||||||
HOOK(IsInvulnerable, targetSource, attack, target.GetRaw(), &invulnerable);
|
HOOK(IsInvulnerable, target, attack, target.GetRaw(), &invulnerable);
|
||||||
if (invulnerable) {
|
if (invulnerable) {
|
||||||
// TODO: We should probably do something when a target is invulnerable.
|
// TODO: We should probably do something when a target is invulnerable.
|
||||||
return;
|
return;
|
||||||
|
@ -147,18 +147,28 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
||||||
|
|
||||||
auto numberOfHits = attack->GetNumberOfHits();
|
auto numberOfHits = attack->GetNumberOfHits();
|
||||||
if (numberOfHits == 0) {
|
if (numberOfHits == 0) {
|
||||||
HOOK(OnAttackMiss, targetSource, attack, target.GetRaw());
|
HOOK(OnAttackMiss, target, attack, target.GetRaw());
|
||||||
user->GetBattle()->TriggerEventListener<MissEvent>(user);
|
battle->TriggerEventListener<MissEvent>(user);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto attackData = attack->GetAttack()->GetAttack();
|
auto& learnedAttack = attack->GetAttack();
|
||||||
auto library = user->GetBattle()->GetLibrary();
|
AssertNotNull(learnedAttack);
|
||||||
|
auto& attackData = learnedAttack->GetAttack();
|
||||||
|
AssertNotNull(attackData);
|
||||||
|
|
||||||
|
auto& library = battle->GetLibrary();
|
||||||
AssertNotNull(library)
|
AssertNotNull(library)
|
||||||
auto& dmgLibrary = library->GetDamageLibrary();
|
auto& dmgLibrary = library->GetDamageLibrary();
|
||||||
auto hitIterator = attack->GetTargetIteratorBegin(target.GetRaw());
|
auto& typeLibrary = library->GetTypeLibrary();
|
||||||
|
auto& miscLibrary = library->GetMiscLibrary();
|
||||||
|
AssertNotNull(dmgLibrary)
|
||||||
|
AssertNotNull(typeLibrary)
|
||||||
|
AssertNotNull(miscLibrary)
|
||||||
|
|
||||||
|
auto hitIterator = attack->GetTargetIteratorBegin(target);
|
||||||
for (uint8_t hitIndex = 0; hitIndex < numberOfHits; hitIndex++) {
|
for (uint8_t hitIndex = 0; hitIndex < numberOfHits; hitIndex++) {
|
||||||
if (user->GetBattle()->HasEnded())
|
if (battle->HasEnded())
|
||||||
return;
|
return;
|
||||||
if (user->IsFainted()) {
|
if (user->IsFainted()) {
|
||||||
break;
|
break;
|
||||||
|
@ -167,28 +177,34 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto& hit = hitIterator[hitIndex];
|
auto& hit = hitIterator[hitIndex];
|
||||||
uint8_t hitType = attack->GetAttack()->GetAttack()->GetType();
|
uint8_t hitType = attackData->GetType();
|
||||||
HOOK(ChangeAttackType, targetSource, attack, target.GetRaw(), hitIndex, &hitType);
|
HOOK(ChangeAttackType, target, attack, target.GetRaw(), hitIndex, &hitType);
|
||||||
hit.SetType(hitType);
|
hit.SetType(hitType);
|
||||||
auto effectiveness = library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes());
|
auto effectiveness = typeLibrary->GetEffectiveness(hitType, target->GetTypes());
|
||||||
HOOK(ChangeEffectiveness, attack, attack, target.GetRaw(), hitIndex, &effectiveness)
|
HOOK(ChangeEffectiveness, attack, attack, target.GetRaw(), hitIndex, &effectiveness)
|
||||||
hit.SetEffectiveness(effectiveness);
|
hit.SetEffectiveness(effectiveness);
|
||||||
hit.SetCritical(library->GetMiscLibrary()->IsCritical(attack, target.GetRaw(), hitIndex));
|
hit.SetCritical(miscLibrary->IsCritical(attack, target.GetRaw(), hitIndex));
|
||||||
hit.SetBasePower(dmgLibrary->GetBasePower(attack, target.GetRaw(), hitIndex, hit));
|
hit.SetBasePower(dmgLibrary->GetBasePower(attack, target.GetRaw(), hitIndex, hit));
|
||||||
hit.SetDamage(dmgLibrary->GetDamage(attack, target.GetRaw(), hitIndex, hit));
|
hit.SetDamage(dmgLibrary->GetDamage(attack, target.GetRaw(), hitIndex, hit));
|
||||||
|
|
||||||
if (attackData->GetCategory() == Library::AttackCategory::Status) {
|
if (attackData->GetCategory() == Library::AttackCategory::Status) {
|
||||||
if (attackData->HasSecondaryEffect()) {
|
if (attackData->HasSecondaryEffect()) {
|
||||||
|
try {
|
||||||
auto& effect = attackData->GetSecondaryEffect();
|
auto& effect = attackData->GetSecondaryEffect();
|
||||||
bool hasSecondaryEffect;
|
bool hasSecondaryEffect;
|
||||||
if (effect->GetChance() == -1) {
|
if (effect->GetChance() == -1) {
|
||||||
hasSecondaryEffect = true;
|
hasSecondaryEffect = true;
|
||||||
} else {
|
} else {
|
||||||
hasSecondaryEffect =
|
hasSecondaryEffect =
|
||||||
user->GetBattle()->GetRandom()->EffectChance(effect->GetChance(), attack, target.GetRaw());
|
battle->GetRandom()->EffectChance(effect->GetChance(), attack, target.GetRaw());
|
||||||
}
|
}
|
||||||
if (hasSecondaryEffect) {
|
if (hasSecondaryEffect) {
|
||||||
HOOK(OnSecondaryEffect, userSource, attack, target.GetRaw(), hitIndex);
|
HOOK(OnSecondaryEffect, user, attack, target.GetRaw(), hitIndex);
|
||||||
|
}
|
||||||
|
} catch (const CreatureException& e) {
|
||||||
|
throw e;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
THROW_CREATURE("Exception during status attack effect handling: " << e.what() << ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -202,18 +218,26 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
||||||
|
|
||||||
if (attackData->HasSecondaryEffect() && !user->IsFainted()) {
|
if (attackData->HasSecondaryEffect() && !user->IsFainted()) {
|
||||||
bool preventSecondary = false;
|
bool preventSecondary = false;
|
||||||
HOOK(PreventSecondaryEffects, targetSource, attack, target.GetRaw(), hitIndex, &preventSecondary);
|
HOOK(PreventSecondaryEffects, target, attack, target.GetRaw(), hitIndex, &preventSecondary);
|
||||||
if (!preventSecondary) {
|
if (!preventSecondary) {
|
||||||
|
try {
|
||||||
auto& effect = attackData->GetSecondaryEffect();
|
auto& effect = attackData->GetSecondaryEffect();
|
||||||
bool hasSecondaryEffect;
|
bool hasSecondaryEffect;
|
||||||
if (effect->GetChance() == -1) {
|
if (effect->GetChance() == -1) {
|
||||||
hasSecondaryEffect = true;
|
hasSecondaryEffect = true;
|
||||||
} else {
|
} else {
|
||||||
hasSecondaryEffect = user->GetBattle()->GetRandom()->EffectChance(effect->GetChance(),
|
auto random = battle->GetRandom();
|
||||||
attack, target.GetRaw());
|
AssertNotNull(random);
|
||||||
|
hasSecondaryEffect = random->EffectChance(effect->GetChance(), attack, target.GetRaw());
|
||||||
}
|
}
|
||||||
if (hasSecondaryEffect) {
|
if (hasSecondaryEffect) {
|
||||||
HOOK(OnSecondaryEffect, userSource, attack, target.GetRaw(), hitIndex);
|
HOOK(OnSecondaryEffect, user, attack, target.GetRaw(), hitIndex);
|
||||||
|
}
|
||||||
|
} catch (const CreatureException& e) {
|
||||||
|
throw e;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
THROW_CREATURE("Exception during offensive attack secondary effect handling: " << e.what()
|
||||||
|
<< ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +246,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user->IsFainted()) {
|
if (!user->IsFainted()) {
|
||||||
HOOK(OnAfterHits, userSource, attack, target.GetRaw());
|
HOOK(OnAfterHits, user, attack, target.GetRaw());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,13 +103,14 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
void RegisterEventListener(EventHook::EventHookFunc listener) { this->_eventHook.RegisterListener(listener); }
|
void RegisterEventListener(EventHook::EventHookFunc listener) { this->_eventHook.RegisterListener(listener); }
|
||||||
template <EventDataType T, class... parameters> void TriggerEventListener(parameters... args) {
|
template <EventDataType T, class... parameters> void TriggerEventListener(parameters... args) {
|
||||||
this->_eventHook.Trigger<T>(args...);
|
try_creature(this->_eventHook.Trigger<T>(args...);, "Exception occurred during event trigger.");
|
||||||
}
|
}
|
||||||
EventHook& GetEventHook() noexcept { return _eventHook; }
|
EventHook& GetEventHook() noexcept { return _eventHook; }
|
||||||
const EventHook& GetEventHook() const noexcept { return _eventHook; }
|
const EventHook& GetEventHook() const noexcept { return _eventHook; }
|
||||||
|
|
||||||
template <HistoryElementType T, class... parameters> void RegisterHistoryElement(parameters... args) {
|
template <HistoryElementType T, class... parameters> void RegisterHistoryElement(parameters... args) {
|
||||||
this->_historyHolder.Register<T>(args...);
|
try_creature(this->_historyHolder.Register<T>(args...);
|
||||||
|
, "Exception occurred during history element registration.");
|
||||||
}
|
}
|
||||||
const HistoryHolder& GetHistory() const noexcept { return _historyHolder; }
|
const HistoryHolder& GetHistory() const noexcept { return _historyHolder; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,20 +36,19 @@ namespace CreatureLib::Battling {
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ArbUt::BorrowedPtr<Creature>* _targets;
|
|
||||||
uint8_t _targetCount;
|
|
||||||
uint8_t _numberHits;
|
uint8_t _numberHits;
|
||||||
std::unique_ptr<HitData[]> _hits;
|
std::unique_ptr<HitData[]> _hits;
|
||||||
ArbUt::BorrowedPtr<Creature> _user;
|
ArbUt::BorrowedPtr<Creature> _user;
|
||||||
ArbUt::BorrowedPtr<LearnedAttack> _attack;
|
ArbUt::BorrowedPtr<LearnedAttack> _attack;
|
||||||
std::unique_ptr<Script> _script = nullptr;
|
std::unique_ptr<Script> _script = nullptr;
|
||||||
|
ArbUt::List<ArbUt::BorrowedPtr<Creature>> _targets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExecutingAttack(const ArbUt::List<ArbUt::BorrowedPtr<Creature>>& targets, uint8_t numberHits,
|
ExecutingAttack(const ArbUt::List<ArbUt::BorrowedPtr<Creature>>& targets, uint8_t numberHits,
|
||||||
ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<LearnedAttack>& attack,
|
ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<LearnedAttack>& attack,
|
||||||
const std::unique_ptr<Script>& script)
|
const std::unique_ptr<Script>& script)
|
||||||
: _targets(targets.RawData()), _targetCount(targets.Count()), _numberHits(numberHits),
|
: _numberHits(numberHits), _hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user),
|
||||||
_hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user), _attack(attack) {
|
_attack(attack), _targets(targets) {
|
||||||
AssertNotNull(user)
|
AssertNotNull(user)
|
||||||
AssertNotNull(attack)
|
AssertNotNull(attack)
|
||||||
// Take ownership of the script of the attack choice, and give attack choice our initial nullptr.
|
// Take ownership of the script of the attack choice, and give attack choice our initial nullptr.
|
||||||
|
@ -61,7 +60,7 @@ namespace CreatureLib::Battling {
|
||||||
virtual ~ExecutingAttack() noexcept = default;
|
virtual ~ExecutingAttack() noexcept = default;
|
||||||
|
|
||||||
HitData& GetHitData(ArbUt::BorrowedPtr<Creature> creature, uint8_t hit) {
|
HitData& GetHitData(ArbUt::BorrowedPtr<Creature> creature, uint8_t hit) {
|
||||||
for (uint8_t i = 0; i < _targetCount; i++) {
|
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||||
if (_targets[i] == creature) {
|
if (_targets[i] == creature) {
|
||||||
return _hits[i * _numberHits + hit];
|
return _hits[i * _numberHits + hit];
|
||||||
}
|
}
|
||||||
|
@ -70,7 +69,7 @@ namespace CreatureLib::Battling {
|
||||||
}
|
}
|
||||||
|
|
||||||
HitData* GetTargetIteratorBegin(ArbUt::BorrowedPtr<Creature> creature) {
|
HitData* GetTargetIteratorBegin(ArbUt::BorrowedPtr<Creature> creature) {
|
||||||
for (uint8_t i = 0; i < _targetCount; i++) {
|
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||||
if (_targets[i] == creature) {
|
if (_targets[i] == creature) {
|
||||||
return &_hits[i * _numberHits];
|
return &_hits[i * _numberHits];
|
||||||
}
|
}
|
||||||
|
@ -79,7 +78,7 @@ namespace CreatureLib::Battling {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsCreatureTarget(ArbUt::BorrowedPtr<Creature> creature) noexcept {
|
bool IsCreatureTarget(ArbUt::BorrowedPtr<Creature> creature) noexcept {
|
||||||
for (uint8_t i = 0; i < _targetCount; i++) {
|
for (uint8_t i = 0; i < _targets.Count(); i++) {
|
||||||
if (_targets[i] == creature) {
|
if (_targets[i] == creature) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -87,9 +86,9 @@ namespace CreatureLib::Battling {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t GetTargetCount() const noexcept { return _targetCount; }
|
inline uint8_t GetTargetCount() const noexcept { return _targets.Count(); }
|
||||||
|
|
||||||
inline const ArbUt::BorrowedPtr<Creature>* GetTargets() const noexcept { return _targets; }
|
inline const ArbUt::List<ArbUt::BorrowedPtr<Creature>>& GetTargets() const noexcept { return _targets; }
|
||||||
inline uint8_t GetNumberOfHits() const noexcept { return _numberHits; }
|
inline uint8_t GetNumberOfHits() const noexcept { return _numberHits; }
|
||||||
|
|
||||||
inline const ArbUt::BorrowedPtr<Creature>& GetUser() noexcept { return _user; }
|
inline const ArbUt::BorrowedPtr<Creature>& GetUser() noexcept { return _user; }
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#define HOOK(hookName, source, ...) \
|
#define HOOK(hookName, source, ...) \
|
||||||
{ \
|
{ \
|
||||||
|
try { \
|
||||||
auto aggregator = source->GetScriptIterator(); \
|
auto aggregator = source->GetScriptIterator(); \
|
||||||
while (aggregator.HasNext()) { \
|
while (aggregator.HasNext()) { \
|
||||||
auto next = aggregator.GetNext(); \
|
auto next = aggregator.GetNext(); \
|
||||||
|
@ -11,19 +12,9 @@
|
||||||
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
|
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
}
|
} catch (const CreatureException& e) { \
|
||||||
|
throw e; \
|
||||||
#define HOOK_LOCAL(hookName, source, ...) \
|
|
||||||
{ \
|
|
||||||
auto aggregator = source.GetScriptIterator(); \
|
|
||||||
while (aggregator.HasNext()) { \
|
|
||||||
auto next = aggregator.GetNext(); \
|
|
||||||
if (next == nullptr) \
|
|
||||||
continue; \
|
|
||||||
try { \
|
|
||||||
next->hookName(__VA_ARGS__); \
|
|
||||||
} catch (const std::exception& e) { \
|
} catch (const std::exception& e) { \
|
||||||
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
|
THROW_CREATURE("Exception setting up script hook '" #hookName "': " << e.what()) \
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
#ifndef CREATURELIB_CREATUREEXCEPTION_HPP
|
#ifndef CREATURELIB_CREATUREEXCEPTION_HPP
|
||||||
#define CREATURELIB_CREATUREEXCEPTION_HPP
|
#define CREATURELIB_CREATUREEXCEPTION_HPP
|
||||||
|
|
||||||
|
#include <Arbutils/Exception.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||||
|
|
||||||
class CreatureException : public std::runtime_error {
|
class CreatureException : public ArbUt::Exception {
|
||||||
public:
|
public:
|
||||||
explicit CreatureException(const std::string& error) : std::runtime_error(error) {}
|
explicit CreatureException(const std::string& error) : ArbUt::Exception(error) {}
|
||||||
virtual ~CreatureException() = default;
|
virtual ~CreatureException() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ TEST_CASE("When throwing exception, what() is readable", "[Utilities]") {
|
||||||
bool hasCaught = false;
|
bool hasCaught = false;
|
||||||
try {
|
try {
|
||||||
THROW_CREATURE("foobar");
|
THROW_CREATURE("foobar");
|
||||||
} catch (const std::exception& e) {
|
} catch (const ArbUt::Exception& e) {
|
||||||
hasCaught = true;
|
hasCaught = true;
|
||||||
INFO(e.what());
|
INFO(e.what());
|
||||||
REQUIRE(std::string(e.what()) == "[ExceptionTests.cpp:9] foobar");
|
REQUIRE(std::string(e.what()) == "[ExceptionTests.cpp:9] foobar");
|
||||||
|
|
Loading…
Reference in New Issue