From 718af15b0763ce2e06f1648443f93d30174e8514 Mon Sep 17 00:00:00 2001 From: Andrea Blankenstijn Date: Sat, 14 Aug 2021 11:04:48 +0200 Subject: [PATCH] don't inherit directly from std::excption but from derived type and use their constructor. --- examples/run.hpp | 2 -- inc/basic_widgets/core/type/exception.hpp | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/run.hpp b/examples/run.hpp index dad59cd..963b91d 100644 --- a/examples/run.hpp +++ b/examples/run.hpp @@ -88,8 +88,6 @@ void run_example( layout.render(); renderer->present(); } - } catch (const bwidgets::BaseException& e) { - std::cerr << "Error: " << e.what << std::endl; } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; } diff --git a/inc/basic_widgets/core/type/exception.hpp b/inc/basic_widgets/core/type/exception.hpp index b419c38..d4f6dcb 100644 --- a/inc/basic_widgets/core/type/exception.hpp +++ b/inc/basic_widgets/core/type/exception.hpp @@ -2,7 +2,7 @@ #define BWIDGETS_EXCEPTION_HPP #include -#include +#include #include #include @@ -10,11 +10,9 @@ namespace bwidgets { - struct BaseException : std::exception + struct BaseException : std::runtime_error { - std::string what; - - BaseException(std::string w) noexcept : what(std::move(w)) {} + using runtime_error::runtime_error; }; template