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
Thrown when an unexpected error occurs during the analysis (e.g., when the SAT solver returns an erro...
std::string what() const override
A human readable description of what went wrong.
std::string reason
The reason this exception was generated.
analysis_exceptiont(std::string reason)
Base class for exceptions thrown in the cprover project.
virtual std::string what() const =0
A human readable description of what went wrong.
virtual ~cprover_exception_baset()=default
Thrown when failing to deserialize a value from some low level format, like JSON or raw bytes.
std::string what() const override
A human readable description of what went wrong.
deserialization_exceptiont(std::string message)
Thrown when a goto program that's being processed is in an invalid format, for example passing the wr...
incorrect_goto_program_exceptiont(std::string message)
std::string what() const override
A human readable description of what went wrong.
Thrown when users pass incorrect command line arguments, for example passing no files to analysis or ...
invalid_command_line_argument_exceptiont(std::string reason, std::string option, std::string correct_input="")
std::string what() const override
A human readable description of what went wrong.
std::string reason
The reason this exception was generated.
std::string correct_input
In case we have samples of correct input to the option.
std::string option
The full command line option (not the argument) that got erroneous input.
Thrown when we can't handle something in an input source file.
std::string what() const override
A human readable description of what went wrong.
invalid_source_file_exceptiont(std::string reason)
Thrown when some external system fails unexpectedly.
system_exceptiont(std::string message)
std::string what() const override
A human readable description of what went wrong.
std::string message
Thrown when we encounter an instruction, parameters to an instruction etc.
std::string what() const override
A human readable description of what went wrong.
std::string message
The unsupported operation causing this fault to occur.
unsupported_operation_exceptiont(std::string message)
std::string assemble_diagnostics()
Definition: invariant.h:342