diff --git a/lib/fnd/exception.cpp b/lib/fnd/exception.cpp index 969a3a8..ed2c609 100644 --- a/lib/fnd/exception.cpp +++ b/lib/fnd/exception.cpp @@ -5,7 +5,7 @@ using namespace fnd; Exception::Exception() noexcept : what_(""), module_(""), - level_(E_FATAL) + error_("") { } @@ -13,33 +13,23 @@ Exception::Exception() noexcept : Exception::Exception(const std::string & what) noexcept : what_(what), module_(""), - level_(E_FATAL) -{ -} - -Exception::Exception(const std::string & what, ExceptionLevel level) noexcept : - what_(what), - module_(""), - level_(level) + error_(what) { } Exception::Exception(const std::string & module, const std::string & what) noexcept : - what_(what), + what_(""), module_(module), - level_(E_FATAL) -{ -} - -Exception::Exception(const std::string & module, const std::string & what, ExceptionLevel level) noexcept : -what_(what), - module_(module), - level_(level) -{ -} - -Exception::~Exception() + error_(what) { + if (module_.length() > 0) + { + what_ = "[" + module_ + " ERROR] " + error_; + } + else + { + what_ = error_; + } } const char* Exception::what() const noexcept @@ -52,7 +42,7 @@ const char* Exception::module() const noexcept return module_.c_str(); } -bool Exception::is_fatal() const noexcept +const char * fnd::Exception::error() const noexcept { - return level_ == E_FATAL; + return nullptr; } diff --git a/lib/fnd/exception.h b/lib/fnd/exception.h index 3921c06..e26c45e 100644 --- a/lib/fnd/exception.h +++ b/lib/fnd/exception.h @@ -7,28 +7,17 @@ namespace fnd class Exception : public std::exception { public: - enum ExceptionLevel - { - E_RECOVERABLE, - E_FATAL, - }; - Exception() noexcept; Exception(const std::string& what) noexcept; - Exception(const std::string& what, ExceptionLevel level) noexcept; Exception(const std::string& module, const std::string& what) noexcept; - Exception(const std::string& module, const std::string& what, ExceptionLevel level) noexcept; - - - ~Exception(); const char* what() const noexcept; const char* module() const noexcept; - bool is_fatal() const noexcept; + const char* error() const noexcept; private: std::string what_; std::string module_; - ExceptionLevel level_; + std::string error_; }; } diff --git a/programs/ncatool/main.cpp b/programs/ncatool/main.cpp index 1e2e6a3..a0cfd1e 100644 --- a/programs/ncatool/main.cpp +++ b/programs/ncatool/main.cpp @@ -102,7 +102,7 @@ int main(int argc, char** argv) } } catch (const fnd::Exception& e) { - printf("[%s%sERROR] %s\n", e.module(), strlen(e.module()) > 0 ? " " : "", e.what()); + printf("%s\n",e.what()); } return 0;