diff --git a/src/util/exception_utils.cpp b/src/util/exception_utils.cpp index 148ddc742cd..8db0baedeed 100644 --- a/src/util/exception_utils.cpp +++ b/src/util/exception_utils.cpp @@ -8,6 +8,8 @@ Author: Fotis Koutoulakis, fotis.koutoulakis@diffblue.com #include "exception_utils.h" +#include + std::string invalid_user_input_exceptiont::what() const noexcept { std::string res; @@ -18,3 +20,11 @@ std::string invalid_user_input_exceptiont::what() const noexcept res += correct_input + "\n"; return res; } + +deserialization_exceptiont::deserialization_exceptiont(std::string message) + : message(std::move(message)) +{} + +std::string deserialization_exceptiont::what() const noexcept { + return message; +} diff --git a/src/util/exception_utils.h b/src/util/exception_utils.h index 4c871b94fbf..b6ae1b54097 100644 --- a/src/util/exception_utils.h +++ b/src/util/exception_utils.h @@ -33,4 +33,32 @@ class invalid_user_input_exceptiont std::string what() const noexcept; }; +class system_exceptiont +{ +private: + std::string reason; + +public: + system_exceptiont(const std::string &reason) : reason(reason) + { + } + + std::string what() const noexcept + { + std::string res; + res += "System Exception\n"; + res += "Reason: " + reason + "\n"; + return res; + } +}; + +class deserialization_exceptiont +{ +public: + explicit deserialization_exceptiont(std::string message); + std::string what() const noexcept; +private: + std::string message; +}; + #endif // CPROVER_UTIL_EXCEPTION_UTILS_H diff --git a/src/util/parse_options.cpp b/src/util/parse_options.cpp index b5a1b7e9b1f..e27a4a39e6e 100644 --- a/src/util/parse_options.cpp +++ b/src/util/parse_options.cpp @@ -76,6 +76,17 @@ int parse_options_baset::main() std::cerr << e.what() << "\n"; return CPROVER_EXIT_USAGE_ERROR; } + catch(system_exceptiont &e) + { + std::cerr << e.what() << "\n"; + return CPROVER_EXIT_EXCEPTION; + } + catch (const deserialization_exceptiont &e) + { + std::cerr << e.what() << '\n'; + return CPROVER_EXIT_EXCEPTION; + } + return CPROVER_EXIT_SUCCESS; }