diff options
author | Gereon Kremer <gereon.kremer@cs.rwth-aachen.de> | 2021-04-14 22:35:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-14 20:35:07 +0000 |
commit | 485b3db20d182b0d621c002bb355c9d1ec2429e9 (patch) | |
tree | 0796088bfe4b70055c298fa6a3d13f246c403ea2 /src/api/cpp | |
parent | 9f14a0d6feca8d8ba727f88ef7dda5268183bb56 (diff) |
Improve documentation for API exceptions (#6340)
Diffstat (limited to 'src/api/cpp')
-rw-r--r-- | src/api/cpp/cvc5.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/api/cpp/cvc5.h b/src/api/cpp/cvc5.h index 1e0e17e52..b541c742e 100644 --- a/src/api/cpp/cvc5.h +++ b/src/api/cpp/cvc5.h @@ -59,22 +59,55 @@ struct APIStatistics; /* Exception */ /* -------------------------------------------------------------------------- */ +/** + * Base class for all API exceptions. + * If thrown, all API objects may be in an unsafe state. + */ class CVC4_EXPORT CVC4ApiException : public std::exception { public: + /** + * Construct with message from a string. + * @param str The error message. + */ CVC4ApiException(const std::string& str) : d_msg(str) {} + /** + * Construct with message from a string stream. + * @param stream The error message. + */ CVC4ApiException(const std::stringstream& stream) : d_msg(stream.str()) {} - std::string getMessage() const { return d_msg; } + /** + * Retrieve the message from this exception. + * @return The error message. + */ + const std::string& getMessage() const { return d_msg; } + /** + * Retrieve the message as a C-style array. + * @return The error message. + */ const char* what() const noexcept override { return d_msg.c_str(); } private: + /** The stored error message. */ std::string d_msg; }; +/** + * A recoverable API exception. + * If thrown, API objects can still be used. + */ class CVC4_EXPORT CVC4ApiRecoverableException : public CVC4ApiException { public: + /** + * Construct with message from a string. + * @param str The error message. + */ CVC4ApiRecoverableException(const std::string& str) : CVC4ApiException(str) {} + /** + * Construct with message from a string stream. + * @param stream The error message. + */ CVC4ApiRecoverableException(const std::stringstream& stream) : CVC4ApiException(stream.str()) { |