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();
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;
}

View File

@ -2,7 +2,7 @@
#define BWIDGETS_EXCEPTION_HPP
#include <any>
#include <exception>
#include <stdexcept>
#include <functional>
#include <map>
@ -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<typename T>