cprover
exception_utils.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Exception helper utilities
4 
5 Author: Fotis Koutoulakis, fotis.koutoulakis@diffblue.com
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_UTIL_EXCEPTION_UTILS_H
10 #define CPROVER_UTIL_EXCEPTION_UTILS_H
11 
12 #include <string>
13 
14 #include "invariant.h"
15 #include "source_location.h"
16 
25 {
26 public:
30  virtual std::string what() const = 0;
31  virtual ~cprover_exception_baset() = default;
32 };
33 
38 {
40  std::string reason;
43  std::string option;
45  std::string correct_input;
46 
47 public:
49  std::string reason,
50  std::string option,
51  std::string correct_input = "");
52 
53  std::string what() const override;
54 };
55 
61 {
62 public:
63  explicit system_exceptiont(std::string message);
64  std::string what() const override;
65 
66 private:
67  std::string message;
68 };
69 
73 {
74 public:
75  explicit deserialization_exceptiont(std::string message);
76 
77  std::string what() const override;
78 
79 private:
80  std::string message;
81 };
82 
90 {
91 public:
92  explicit incorrect_goto_program_exceptiont(std::string message);
93 
94  template <typename Diagnostic, typename... Diagnostics>
96  std::string message,
97  Diagnostic &&diagnostic,
98  Diagnostics &&... diagnostics);
99 
100  template <typename... Diagnostics>
102  std::string message,
104  Diagnostics &&... diagnostics);
105 
106  std::string what() const override;
107 
108 private:
109  std::string message;
111 
112  std::string diagnostics;
113 };
114 
115 template <typename Diagnostic, typename... Diagnostics>
117  std::string message,
118  Diagnostic &&diagnostic,
119  Diagnostics &&... diagnostics)
120  : message(std::move(message)),
121  source_location(),
122  diagnostics(detail::assemble_diagnostics(
123  std::forward<Diagnostic>(diagnostic),
124  std::forward<Diagnostics>(diagnostics)...))
125 {
126 }
127 
128 template <typename... Diagnostics>
130  std::string message,
131  source_locationt source_location,
132  Diagnostics &&... diagnostics)
133  : message(std::move(message)),
134  source_location(std::move(source_location)),
135  diagnostics(
136  detail::assemble_diagnostics(std::forward<Diagnostics>(diagnostics)...))
137 {
138 }
139 
144 {
145 public:
146  explicit unsupported_operation_exceptiont(std::string message);
147  std::string what() const override;
148 
149 private:
151  std::string message;
152 };
153 
157 {
158 public:
159  explicit analysis_exceptiont(std::string reason);
160  std::string what() const override;
161 
162 private:
164  std::string reason;
165 };
166 
171 {
172 public:
173  explicit invalid_source_file_exceptiont(std::string reason);
174  std::string what() const override;
175 
176 private:
177  std::string reason;
178 };
179 
180 #endif // CPROVER_UTIL_EXCEPTION_UTILS_H
detail::assemble_diagnostics
std::string assemble_diagnostics()
Definition: invariant.h:343
deserialization_exceptiont::message
std::string message
Definition: exception_utils.h:80
deserialization_exceptiont
Thrown when failing to deserialize a value from some low level format, like JSON or raw bytes.
Definition: exception_utils.h:73
deserialization_exceptiont::deserialization_exceptiont
deserialization_exceptiont(std::string message)
Definition: exception_utils.cpp:47
unsupported_operation_exceptiont
Thrown when we encounter an instruction, parameters to an instruction etc.
Definition: exception_utils.h:144
system_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:42
invalid_source_file_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:104
system_exceptiont::message
std::string message
Definition: exception_utils.h:67
incorrect_goto_program_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:64
analysis_exceptiont::reason
std::string reason
The reason this exception was generated.
Definition: exception_utils.h:164
detail
Definition: expr_cast.h:52
invalid_source_file_exceptiont
Thrown when we can't handle something in an input source file.
Definition: exception_utils.h:171
unsupported_operation_exceptiont::message
std::string message
The unsupported operation causing this fault to occur.
Definition: exception_utils.h:151
invalid_source_file_exceptiont::reason
std::string reason
Definition: exception_utils.h:177
incorrect_goto_program_exceptiont
Thrown when a goto program that's being processed is in an invalid format, for example passing the wr...
Definition: exception_utils.h:90
unsupported_operation_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:83
message
static const char * message(const static_verifier_resultt::statust &status)
Makes a status message string from a status.
Definition: static_verifier.cpp:74
invalid_command_line_argument_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:12
invalid_source_file_exceptiont::invalid_source_file_exceptiont
invalid_source_file_exceptiont(std::string reason)
Definition: exception_utils.cpp:98
incorrect_goto_program_exceptiont::diagnostics
std::string diagnostics
Definition: exception_utils.h:112
cprover_exception_baset::what
virtual std::string what() const =0
A human readable description of what went wrong.
system_exceptiont
Thrown when some external system fails unexpectedly.
Definition: exception_utils.h:61
source_location.h
incorrect_goto_program_exceptiont::incorrect_goto_program_exceptiont
incorrect_goto_program_exceptiont(std::string message)
Definition: exception_utils.cpp:57
analysis_exceptiont::analysis_exceptiont
analysis_exceptiont(std::string reason)
Definition: exception_utils.cpp:88
source_locationt
Definition: source_location.h:20
incorrect_goto_program_exceptiont::source_location
source_locationt source_location
Definition: exception_utils.h:110
unsupported_operation_exceptiont::unsupported_operation_exceptiont
unsupported_operation_exceptiont(std::string message)
Definition: exception_utils.cpp:77
invalid_command_line_argument_exceptiont::invalid_command_line_argument_exceptiont
invalid_command_line_argument_exceptiont(std::string reason, std::string option, std::string correct_input="")
Definition: exception_utils.cpp:27
invariant.h
incorrect_goto_program_exceptiont::message
std::string message
Definition: exception_utils.h:109
invalid_command_line_argument_exceptiont::option
std::string option
The full command line option (not the argument) that got erroneous input.
Definition: exception_utils.h:43
system_exceptiont::system_exceptiont
system_exceptiont(std::string message)
Definition: exception_utils.cpp:37
invalid_command_line_argument_exceptiont::correct_input
std::string correct_input
In case we have samples of correct input to the option.
Definition: exception_utils.h:45
analysis_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:93
invalid_command_line_argument_exceptiont
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
Definition: exception_utils.h:38
invalid_command_line_argument_exceptiont::reason
std::string reason
The reason this exception was generated.
Definition: exception_utils.h:40
cprover_exception_baset::~cprover_exception_baset
virtual ~cprover_exception_baset()=default
cprover_exception_baset
Base class for exceptions thrown in the cprover project.
Definition: exception_utils.h:25
deserialization_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:52
analysis_exceptiont
Thrown when an unexpected error occurs during the analysis (e.g., when the SAT solver returns an erro...
Definition: exception_utils.h:157