14
14
#include < fstream>
15
15
#include < iostream>
16
16
#include < memory>
17
+ #include < string>
17
18
19
+ #include < util/exception_utils.h>
18
20
#include < util/make_unique.h>
19
21
#include < util/unicode.h>
20
22
#include < util/version.h>
@@ -164,8 +166,10 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
164
166
{
165
167
if (solver==smt2_dect::solvert::GENERIC)
166
168
{
167
- error () << " please use --outfile" << eom;
168
- throw 0 ;
169
+ throw invalid_user_input_exceptiont (
170
+ " required filename not provided" ,
171
+ " --outfile" ,
172
+ " provide a filename with --outfile" );
169
173
}
170
174
171
175
auto smt2_dec = util_make_unique<smt2_dect>(
@@ -207,8 +211,8 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
207
211
208
212
if (!*out)
209
213
{
210
- error () << " failed to open " << filename << eom;
211
- throw 0 ;
214
+ throw invalid_user_input_exceptiont (
215
+ " failed to open file: " + filename, " --outfile " ) ;
212
216
}
213
217
214
218
auto smt2_conv = util_make_unique<smt2_convt>(
@@ -232,18 +236,32 @@ void cbmc_solverst::no_beautification()
232
236
{
233
237
if (options.get_bool_option (" beautify" ))
234
238
{
235
- error () << " sorry, this solver does not support beautification " << eom;
236
- throw 0 ;
239
+ throw invalid_user_input_exceptiont (
240
+ " the chosen solver does not support beautification " , " --beautify " ) ;
237
241
}
238
242
}
239
243
240
244
void cbmc_solverst::no_incremental_check ()
241
245
{
242
- if (options.get_bool_option (" all-properties" ) ||
243
- options.get_option (" cover" )!=" " ||
244
- options.get_option (" incremental-check" )!=" " )
246
+ const bool all_properties = options.get_bool_option (" all-properties" );
247
+ const bool cover = options.is_set (" cover" );
248
+ const bool incremental_check = options.is_set (" incremental-check" );
249
+
250
+ if (all_properties)
251
+ {
252
+ throw invalid_user_input_exceptiont (
253
+ " the chosen solver does not support incremental solving" ,
254
+ " --all_properties" );
255
+ }
256
+ else if (cover)
257
+ {
258
+ throw invalid_user_input_exceptiont (
259
+ " the chosen solver does not support incremental solving" , " --cover" );
260
+ }
261
+ else if (incremental_check)
245
262
{
246
- error () << " sorry, this solver does not support incremental solving" << eom;
247
- throw 0 ;
263
+ throw invalid_user_input_exceptiont (
264
+ " the chosen solver does not support incremental solving" ,
265
+ " --incremental-check" );
248
266
}
249
267
}
0 commit comments