From 32a70aeb9e8fc463ab3134ce38c0c0878644adef Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Thu, 27 Apr 2017 16:37:26 -0400 Subject: [PATCH] Adding easier-to-subclass error type --- include/CLI/Error.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/CLI/Error.hpp b/include/CLI/Error.hpp index 618ab89c..f28fc078 100644 --- a/include/CLI/Error.hpp +++ b/include/CLI/Error.hpp @@ -39,10 +39,12 @@ enum class ExitCodes { /// All errors derive from this one struct Error : public std::runtime_error { - ExitCodes exit_code; + int exit_code; bool print_help; - int get_exit_code() const {return static_cast(exit_code);} + int get_exit_code() const {return exit_code;} Error(std::string parent, std::string name, ExitCodes exit_code=ExitCodes::BaseClass, bool print_help=true) + : runtime_error(parent + ": " + name), exit_code(static_cast(exit_code)), print_help(print_help) {} + Error(std::string parent, std::string name, int exit_code=static_cast(ExitCodes::BaseClass), bool print_help=true) : runtime_error(parent + ": " + name), exit_code(exit_code), print_help(print_help) {} };