-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathexception_utils.cpp
99 lines (80 loc) · 2.38 KB
/
exception_utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*******************************************************************\
Module: Exception helper utilities
Author: Fotis Koutoulakis, [email protected]
\*******************************************************************/
#include "exception_utils.h"
#include <utility>
std::string cprover_exception_baset::what() const
{
return reason;
}
std::string invalid_command_line_argument_exceptiont::what() const
{
std::string res;
res += "Invalid User Input";
res += "\nOption: " + option;
res += "\nReason: " + reason;
// Print an optional correct usage message assuming correct input parameters have been passed
if(!correct_input.empty())
{
res += "\nSuggestion: " + correct_input;
}
return res;
}
invalid_command_line_argument_exceptiont::
invalid_command_line_argument_exceptiont(
std::string reason,
std::string option,
std::string correct_input)
: cprover_exception_baset(std::move(reason)),
option(std::move(option)),
correct_input(std::move(correct_input))
{
}
system_exceptiont::system_exceptiont(std::string message)
: cprover_exception_baset(std::move(message))
{
}
deserialization_exceptiont::deserialization_exceptiont(std::string message)
: cprover_exception_baset(std::move(message))
{
}
incorrect_goto_program_exceptiont::incorrect_goto_program_exceptiont(
std::string message)
: cprover_exception_baset(std::move(message)),
source_location(source_locationt::nil())
{
}
std::string incorrect_goto_program_exceptiont::what() const
{
std::string ret(reason);
if(!source_location.is_nil())
ret += " (at: " + source_location.as_string() + ")";
if(!diagnostics.empty())
ret += "\n" + diagnostics;
return ret;
}
unsupported_operation_exceptiont::unsupported_operation_exceptiont(
std::string message)
: cprover_exception_baset(std::move(message))
{
}
analysis_exceptiont::analysis_exceptiont(std::string reason)
: cprover_exception_baset(std::move(reason))
{
}
invalid_input_exceptiont::invalid_input_exceptiont(std::string reason)
: cprover_exception_baset(std::move(reason))
{
}
invalid_source_file_exceptiont::invalid_source_file_exceptiont(
std::string reason,
source_locationt source_location)
: invalid_input_exceptiont(std::move(reason)),
source_location(std::move(source_location))
{
}
std::string invalid_source_file_exceptiont::what() const
{
return source_location.as_string() + ": " + reason;
}