23
23
#include < langapi/language.h>
24
24
25
25
#include < goto-programs/rebuild_goto_start_function.h>
26
+ #include < util/exception_utils.h>
26
27
27
28
#include " goto_convert_functions.h"
28
29
#include " read_goto_binary.h"
@@ -36,8 +37,10 @@ goto_modelt initialize_goto_model(
36
37
const std::vector<std::string> &files=cmdline.args ;
37
38
if (files.empty ())
38
39
{
39
- msg.error () << " Please provide a program" << messaget::eom;
40
- throw 0 ;
40
+ throw invalid_command_line_argument_exceptiont (
41
+ " missing program argument" ,
42
+ " filename" ,
43
+ " one or more paths to program files" );
41
44
}
42
45
43
46
std::vector<std::string> binaries, sources;
@@ -69,21 +72,17 @@ goto_modelt initialize_goto_model(
69
72
70
73
if (!infile)
71
74
{
72
- msg.error () << " failed to open input file `" << filename
73
- << ' \' ' << messaget::eom;
74
- throw 0 ;
75
+ throw system_exceptiont (
76
+ " Failed to open input file `" + filename + ' \' ' );
75
77
}
76
78
77
79
language_filet &lf=language_files.add_file (filename);
78
80
lf.language =get_language_from_filename (filename);
79
81
80
82
if (lf.language ==nullptr )
81
83
{
82
- source_locationt location;
83
- location.set_file (filename);
84
- msg.error ().source_location =location;
85
- msg.error () << " failed to figure out type of file" << messaget::eom;
86
- throw 0 ;
84
+ throw invalid_source_file_exceptiont (
85
+ " Failed to figure out type of file `" + filename + ' \' ' );
87
86
}
88
87
89
88
languaget &language=*lf.language ;
@@ -94,8 +93,7 @@ goto_modelt initialize_goto_model(
94
93
95
94
if (language.parse (infile, filename))
96
95
{
97
- msg.error () << " PARSING ERROR" << messaget::eom;
98
- throw 0 ;
96
+ throw invalid_source_file_exceptiont (" PARSING ERROR" );
99
97
}
100
98
101
99
lf.get_modules ();
@@ -105,8 +103,7 @@ goto_modelt initialize_goto_model(
105
103
106
104
if (language_files.typecheck (goto_model.symbol_table ))
107
105
{
108
- msg.error () << " CONVERSION ERROR" << messaget::eom;
109
- throw 0 ;
106
+ throw invalid_source_file_exceptiont (" CONVERSION ERROR" );
110
107
}
111
108
}
112
109
@@ -115,7 +112,10 @@ goto_modelt initialize_goto_model(
115
112
msg.status () << " Reading GOTO program from file" << messaget::eom;
116
113
117
114
if (read_object_and_link (file, goto_model, message_handler))
118
- throw 0 ;
115
+ {
116
+ throw invalid_source_file_exceptiont (
117
+ " failed to read object or link in file `" + file + ' \' ' );
118
+ }
119
119
}
120
120
121
121
bool binaries_provided_start=
@@ -150,14 +150,12 @@ goto_modelt initialize_goto_model(
150
150
151
151
if (entry_point_generation_failed)
152
152
{
153
- msg.error () << " SUPPORT FUNCTION GENERATION ERROR" << messaget::eom;
154
- throw 0 ;
153
+ throw invalid_source_file_exceptiont (" SUPPORT FUNCTION GENERATION ERROR" );
155
154
}
156
155
157
156
if (language_files.final (goto_model.symbol_table ))
158
157
{
159
- msg.error () << " FINAL STAGE CONVERSION ERROR" << messaget::eom;
160
- throw 0 ;
158
+ throw invalid_source_file_exceptiont (" FINAL STAGE CONVERSION ERROR" );
161
159
}
162
160
163
161
msg.status () << " Generating GOTO Program" << messaget::eom;
0 commit comments