aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-27 22:34:49 +0200
committerHampusM <hampus@hampusmat.com>2022-06-27 22:35:57 +0200
commitf5398aa86460daf06020bbc27ab40d432f30abf0 (patch)
treeaffc8ab9245a72bc9b81081bf7f791b0262cee52 /src
parent6b0e2a25cf1e98d3f11d4e6c0305dd327048bbb8 (diff)
refactor: status manager throw when set section title fails
Diffstat (limited to 'src')
-rw-r--r--src/game/status_manager.cpp9
-rw-r--r--src/game/status_manager.hpp2
-rw-r--r--src/interfaces/status_manager.hpp2
3 files changed, 8 insertions, 5 deletions
diff --git a/src/game/status_manager.cpp b/src/game/status_manager.cpp
index e4838cc..fd56627 100644
--- a/src/game/status_manager.cpp
+++ b/src/game/status_manager.cpp
@@ -2,6 +2,7 @@
#include <fmt/core.h>
+#include <stdexcept>
#include <utility>
void StatusManager::bind(const std::shared_ptr<IStatusLine> &statusline) noexcept
@@ -11,12 +12,14 @@ void StatusManager::bind(const std::shared_ptr<IStatusLine> &statusline) noexcep
void StatusManager::set_section_title(
const StatusLineSection &section,
- const std::string_view &title) noexcept
+ const std::string_view &title)
{
if (_section_title_lengths.contains(section))
{
- fmt::print(stderr, "Error: can't set statusbar section title more than once");
- return;
+ throw std::logic_error(fmt::format(
+ "Unable to set statusbar section title to '{}'. Section has already been "
+ "assigned a title",
+ title));
}
_statusline->set_section_status(section, title);
diff --git a/src/game/status_manager.hpp b/src/game/status_manager.hpp
index c101289..b170cf9 100644
--- a/src/game/status_manager.hpp
+++ b/src/game/status_manager.hpp
@@ -17,7 +17,7 @@ public:
void set_section_title(
const StatusLineSection &section,
- const std::string_view &title) noexcept override;
+ const std::string_view &title) override;
void set_section_body(
const StatusLineSection &section,
diff --git a/src/interfaces/status_manager.hpp b/src/interfaces/status_manager.hpp
index 7c56df1..7744eb6 100644
--- a/src/interfaces/status_manager.hpp
+++ b/src/interfaces/status_manager.hpp
@@ -15,7 +15,7 @@ public:
virtual void set_section_title(
const StatusLineSection &section,
- const std::string_view &title) noexcept = 0;
+ const std::string_view &title) = 0;
virtual void set_section_body(
const StatusLineSection &section,