From 3c5b3d5c035e28baf8a4d74b88f0e788f833c8c1 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 5 Jun 2020 15:42:28 +0200 Subject: [PATCH] Fixed potential reaching end of function. --- src/Battling/Flow/ResolveTarget.hpp | 2 ++ src/Library/Exceptions/CreatureException.hpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/Battling/Flow/ResolveTarget.hpp b/src/Battling/Flow/ResolveTarget.hpp index 4667151..e8c3d29 100644 --- a/src/Battling/Flow/ResolveTarget.hpp +++ b/src/Battling/Flow/ResolveTarget.hpp @@ -105,6 +105,8 @@ namespace CreatureLib::Battling { return {battle->GetCreature(index)}; }; } + THROW_CREATURE("Unknown attack target kind: '" << CreatureLib::Library::AttackTargetHelper::ToString(target) + << "'."); } }; } diff --git a/src/Library/Exceptions/CreatureException.hpp b/src/Library/Exceptions/CreatureException.hpp index 8fc500a..c832554 100644 --- a/src/Library/Exceptions/CreatureException.hpp +++ b/src/Library/Exceptions/CreatureException.hpp @@ -10,4 +10,8 @@ public: virtual ~CreatureException() = default; }; +#define THROW_CREATURE(message) \ + std::stringstream ss; \ + ss << message; \ + throw CreatureException(ss.str()); #endif // CREATURELIB_CREATUREEXCEPTION_HPP