17
17
#include < langapi/language.h>
18
18
19
19
#include < fstream>
20
+ #include < util/exception_utils.h>
20
21
21
22
// ! @cond Doxygen_suppress_Lambda_in_initializer_list
22
23
lazy_goto_modelt::lazy_goto_modelt (
@@ -94,8 +95,7 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
94
95
const std::vector<std::string> &files=cmdline.args ;
95
96
if (files.empty ())
96
97
{
97
- msg.error () << " Please provide a program" << messaget::eom;
98
- throw 0 ;
98
+ throw invalid_user_input_exceptiont (" No program provided" , " " , " " );
99
99
}
100
100
101
101
std::vector<std::string> binaries, sources;
@@ -122,9 +122,8 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
122
122
123
123
if (!infile)
124
124
{
125
- msg.error () << " failed to open input file `" << filename
126
- << ' \' ' << messaget::eom;
127
- throw 0 ;
125
+ throw system_exceptiont (
126
+ " failed to open input file `" + filename + ' \' ' );
128
127
}
129
128
130
129
language_filet &lf=add_language_file (filename);
@@ -135,8 +134,10 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
135
134
source_locationt location;
136
135
location.set_file (filename);
137
136
msg.error ().source_location =location;
138
- msg.error () << " failed to figure out type of file" << messaget::eom;
139
- throw 0 ;
137
+ throw deserialization_exceptiont (
138
+ " failed to figure out type of file"
139
+ " \n source location: " +
140
+ location.as_string ());
140
141
}
141
142
142
143
languaget &language=*lf.language ;
@@ -147,8 +148,8 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
147
148
148
149
if (language.parse (infile, filename))
149
150
{
150
- msg. error () << " PARSING ERROR " << messaget::eom;
151
- throw 0 ;
151
+ // TODO more helpful error message
152
+ throw deserialization_exceptiont ( " PARSING ERROR " ) ;
152
153
}
153
154
154
155
lf.get_modules ();
@@ -158,8 +159,8 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
158
159
159
160
if (language_files.typecheck (symbol_table))
160
161
{
161
- msg. error () << " CONVERSION ERROR " << messaget::eom;
162
- throw 0 ;
162
+ // TODO more helpful error message
163
+ throw deserialization_exceptiont ( " CONVERSION ERROR " ) ;
163
164
}
164
165
}
165
166
@@ -168,7 +169,10 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
168
169
msg.status () << " Reading GOTO program from file" << messaget::eom;
169
170
170
171
if (read_object_and_link (file, *goto_model, message_handler))
171
- throw 0 ;
172
+ {
173
+ // TODO more helpful error message
174
+ throw deserialization_exceptiont (" Failed to read/link goto model" );
175
+ }
172
176
}
173
177
174
178
bool binaries_provided_start =
@@ -203,8 +207,8 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
203
207
204
208
if (entry_point_generation_failed)
205
209
{
206
- msg. error () << " SUPPORT FUNCTION GENERATION ERROR " << messaget::eom;
207
- throw 0 ;
210
+ // TODO more helpful error message
211
+ throw deserialization_exceptiont ( " SUPPORT FUNCTION GENERATION ERROR " ) ;
208
212
}
209
213
210
214
// stupid hack
0 commit comments