From f5398aa86460daf06020bbc27ab40d432f30abf0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 27 Jun 2022 22:34:49 +0200 Subject: refactor: status manager throw when set section title fails --- src/game/status_manager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/game/status_manager.cpp') 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 +#include #include void StatusManager::bind(const std::shared_ptr &statusline) noexcept @@ -11,12 +12,14 @@ void StatusManager::bind(const std::shared_ptr &statusline) noexcep void StatusManager::set_section_title( const StatusLineSection §ion, - 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); -- cgit v1.2.3-18-g5258