From 5895c01c4c5fe907b12fc7f569dc9e920fd88b19 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 6 May 2023 12:54:26 +0300 Subject: [PATCH] Make util::not_implemented throw a specific exception type instead of runtime_error --- libs/util/include/psemek/util/not_implemented.hpp | 10 +++++++++- libs/util/source/not_implemented.cpp | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/util/include/psemek/util/not_implemented.hpp b/libs/util/include/psemek/util/not_implemented.hpp index 15a9869d..45dd01e0 100644 --- a/libs/util/include/psemek/util/not_implemented.hpp +++ b/libs/util/include/psemek/util/not_implemented.hpp @@ -1,8 +1,16 @@ #pragma once +#include + namespace psemek::util { - [[noreturn]] void not_implemented(); + struct not_implemented_error + : std::exception + { + char const * what() const noexcept override; + }; + + [[noreturn]] void not_implemented(); } diff --git a/libs/util/source/not_implemented.cpp b/libs/util/source/not_implemented.cpp index 10c39152..70515579 100644 --- a/libs/util/source/not_implemented.cpp +++ b/libs/util/source/not_implemented.cpp @@ -5,9 +5,14 @@ namespace psemek::util { + char const * not_implemented_error::what() const noexcept + { + return "not implemented"; + } + void not_implemented() { - throw std::runtime_error("Not implemented"); + throw not_implemented_error{}; } }