don't inherit directly from std::excption but from derived type and use their constructor.

This commit is contained in:
Andrea Blankenstijn 2021-08-14 11:04:48 +02:00
parent 50a324cc95
commit 718af15b07
2 changed files with 3 additions and 7 deletions

View file

@ -88,8 +88,6 @@ void run_example(
layout.render(); layout.render();
renderer->present(); renderer->present();
} }
} catch (const bwidgets::BaseException& e) {
std::cerr << "Error: " << e.what << std::endl;
} catch (const std::exception& e) { } catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl; std::cerr << "Error: " << e.what() << std::endl;
} }

View file

@ -2,7 +2,7 @@
#define BWIDGETS_EXCEPTION_HPP #define BWIDGETS_EXCEPTION_HPP
#include <any> #include <any>
#include <exception> #include <stdexcept>
#include <functional> #include <functional>
#include <map> #include <map>
@ -10,11 +10,9 @@
namespace bwidgets namespace bwidgets
{ {
struct BaseException : std::exception struct BaseException : std::runtime_error
{ {
std::string what; using runtime_error::runtime_error;
BaseException(std::string w) noexcept : what(std::move(w)) {}
}; };
template<typename T> template<typename T>