summaryrefslogtreecommitdiff
path: root/src/api/cpp/cvc5.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/cpp/cvc5.h')
-rw-r--r--src/api/cpp/cvc5.h35
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())
{
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback