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