diff options
author | Aina Niemetz <aina.niemetz@gmail.com> | 2020-09-22 21:25:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 23:25:07 -0500 |
commit | 24b44a8e559f1d89f309d611922098e667293920 (patch) | |
tree | 01dbbc2a27fd607e8a2ff5f774e19f2fb50554b8 /src | |
parent | e7c50fad0015527e854b3ceee692907e8242a05b (diff) |
New C++ API: Catch and throw recoverable exception. (#5122)
This allows to distinguish recoverable from non-recoverable exceptions,
and recover if possible.
Diffstat (limited to 'src')
-rw-r--r-- | src/api/cvc4cpp.cpp | 4 | ||||
-rw-r--r-- | src/api/cvc4cpp.h | 10 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/api/cvc4cpp.cpp b/src/api/cvc4cpp.cpp index 125e33ba5..08beec35a 100644 --- a/src/api/cvc4cpp.cpp +++ b/src/api/cvc4cpp.cpp @@ -807,6 +807,10 @@ class CVC4ApiExceptionStream { #define CVC4_API_SOLVER_TRY_CATCH_END \ } \ + catch (const CVC4::RecoverableModalException& e) \ + { \ + throw CVC4ApiRecoverableException(e.getMessage()); \ + } \ catch (const CVC4::Exception& e) { throw CVC4ApiException(e.getMessage()); } \ catch (const std::invalid_argument& e) { throw CVC4ApiException(e.what()); } diff --git a/src/api/cvc4cpp.h b/src/api/cvc4cpp.h index 841a8ee8a..31ff13ba0 100644 --- a/src/api/cvc4cpp.h +++ b/src/api/cvc4cpp.h @@ -75,6 +75,16 @@ class CVC4_PUBLIC CVC4ApiException : public std::exception std::string d_msg; }; +class CVC4_PUBLIC CVC4ApiRecoverableException : public CVC4ApiException +{ + public: + CVC4ApiRecoverableException(const std::string& str) : CVC4ApiException(str) {} + CVC4ApiRecoverableException(const std::stringstream& stream) + : CVC4ApiException(stream.str()) + { + } +}; + /* -------------------------------------------------------------------------- */ /* Result */ /* -------------------------------------------------------------------------- */ |