@@ -11,7 +11,24 @@ Author: Fotis Koutoulakis, fotis.koutoulakis@diffblue.com
1111
1212#include < string>
1313
14- class invalid_user_input_exceptiont
14+ #include " source_location.h"
15+
16+ // / Base class for exceptions thrown in the cprover project.
17+ // / Intended to be used as a convenient way to have a
18+ // / "catch all and report errors" from application entry points.
19+ class cprover_exception_baset
20+ {
21+ public:
22+ // / A human readable description of what went wrong.
23+ // / For readability, implementors should not add a leading
24+ // / or trailing newline to this description.
25+ virtual std::string what () const = 0;
26+ };
27+
28+ // / Thrown when users pass incorrect command line arguments,
29+ // / for example passing no files to analysis or setting
30+ // / two mutually exclusive flags
31+ class invalid_user_input_exceptiont : public cprover_exception_baset
1532{
1633 // / The reason this exception was generated.
1734 std::string reason;
@@ -25,12 +42,69 @@ class invalid_user_input_exceptiont
2542 invalid_user_input_exceptiont (
2643 std::string reason,
2744 std::string option,
28- std::string correct_input = " " )
29- : reason(reason), option(option), correct_input(correct_input)
30- {
31- }
45+ std::string correct_input = " " );
46+
47+ std::string what () const override ;
48+ };
49+
50+ // / Thrown when some external system fails unexpectedly.
51+ // / Examples are IO exceptions (files not present, or we don't
52+ // / have the right permissions to interact with them), timeouts for
53+ // / external processes etc
54+ class system_exceptiont : public cprover_exception_baset
55+ {
56+ public:
57+ explicit system_exceptiont (std::string message);
58+ std::string what () const override ;
59+
60+ private:
61+ std::string message;
62+ };
63+
64+ // / Thrown when failing to deserialize a value from some
65+ // / low level format, like JSON or raw bytes
66+ class deserialization_exceptiont : public cprover_exception_baset
67+ {
68+ public:
69+ explicit deserialization_exceptiont (std::string message);
70+
71+ std::string what () const override ;
72+
73+ private:
74+ std::string message;
75+ };
76+
77+ // / Thrown when a goto program that's being processed is in an invalid format,
78+ // / for example passing the wrong number of arguments to functions.
79+ // / Note that this only applies to goto programs that are user provided,
80+ // / that internal transformations on goto programs don't produce invalid
81+ // / programs should be guarded by invariants instead.
82+ // / \see invariant.h
83+ class incorrect_goto_program_exceptiont : public cprover_exception_baset
84+ {
85+ public:
86+ incorrect_goto_program_exceptiont (
87+ std::string message,
88+ source_locationt source_location);
89+ std::string what () const override ;
90+
91+ private:
92+ std::string message;
93+ source_locationt source_location;
94+ };
95+
96+ // / Thrown when we encounter an instruction, parameters to an instruction etc.
97+ // / in a goto program that has some theoretically valid semantics,
98+ // / but that we don't presently have any support for.
99+ class unsupported_operation_exceptiont : public cprover_exception_baset
100+ {
101+ public:
102+ explicit unsupported_operation_exceptiont (std::string message);
103+ std::string what () const override ;
32104
33- std::string what () const noexcept ;
105+ private:
106+ // / The unsupported operation causing this fault to occur.
107+ std::string message;
34108};
35109
36110#endif // CPROVER_UTIL_EXCEPTION_UTILS_H
0 commit comments