cprover
exception_utils.cpp
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 #include "exception_utils.h"
10 #include <utility>
11 
13 {
14  std::string res;
15  res += "Invalid User Input";
16  res += "\nOption: " + option;
17  res += "\nReason: " + reason;
18  // Print an optional correct usage message assuming correct input parameters have been passed
19  if(!correct_input.empty())
20  {
21  res += "\nSuggestion: " + correct_input;
22  }
23  return res;
24 }
25 
28  std::string reason,
29  std::string option,
30  std::string correct_input)
31  : reason(std::move(reason)),
32  option(std::move(option)),
33  correct_input(std::move(correct_input))
34 {
35 }
36 
38  : message(std::move(message))
39 {
40 }
41 
42 std::string system_exceptiont::what() const
43 {
44  return message;
45 }
46 
48  : message(std::move(message))
49 {
50 }
51 
53 {
54  return message;
55 }
56 
58  std::string message)
59  : message(std::move(message))
60 {
62 }
63 
65 {
66  std::string ret(message);
67 
68  if(!source_location.is_nil())
69  ret += " (at: " + source_location.as_string() + ")";
70 
71  if(!diagnostics.empty())
72  ret += "\n" + diagnostics;
73 
74  return ret;
75 }
76 
78  std::string message)
79  : message(std::move(message))
80 {
81 }
82 
84 {
85  return message;
86 }
87 
89  : reason(std::move(reason))
90 {
91 }
92 
93 std::string analysis_exceptiont::what() const
94 {
95  return reason;
96 }
97 
99  std::string reason)
100  : reason(std::move(reason))
101 {
102 }
103 
105 {
106  return reason;
107 }
exception_utils.h
source_locationt::as_string
std::string as_string() const
Definition: source_location.h:26
irept::make_nil
void make_nil()
Definition: irep.h:475
deserialization_exceptiont::message
std::string message
Definition: exception_utils.h:80
deserialization_exceptiont::deserialization_exceptiont
deserialization_exceptiont(std::string message)
Definition: exception_utils.cpp:47
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
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
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
irept::is_nil
bool is_nil() const
Definition: irep.h:398
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
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
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::reason
std::string reason
The reason this exception was generated.
Definition: exception_utils.h:40
deserialization_exceptiont::what
std::string what() const override
A human readable description of what went wrong.
Definition: exception_utils.cpp:52