diff --git a/src/goto-programs/initialize_goto_model.cpp b/src/goto-programs/initialize_goto_model.cpp index 4478dd7d856..8cd410c97a8 100644 --- a/src/goto-programs/initialize_goto_model.cpp +++ b/src/goto-programs/initialize_goto_model.cpp @@ -23,6 +23,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include #include "goto_convert_functions.h" #include "read_goto_binary.h" @@ -36,8 +37,10 @@ goto_modelt initialize_goto_model( const std::vector &files=cmdline.args; if(files.empty()) { - msg.error() << "Please provide a program" << messaget::eom; - throw 0; + throw invalid_command_line_argument_exceptiont( + "missing program argument", + "filename", + "one or more paths to program files"); } std::vector binaries, sources; @@ -69,9 +72,8 @@ goto_modelt initialize_goto_model( if(!infile) { - msg.error() << "failed to open input file `" << filename - << '\'' << messaget::eom; - throw 0; + throw system_exceptiont( + "Failed to open input file `" + filename + '\''); } language_filet &lf=language_files.add_file(filename); @@ -79,11 +81,8 @@ goto_modelt initialize_goto_model( if(lf.language==nullptr) { - source_locationt location; - location.set_file(filename); - msg.error().source_location=location; - msg.error() << "failed to figure out type of file" << messaget::eom; - throw 0; + throw invalid_source_file_exceptiont( + "Failed to figure out type of file `" + filename + '\''); } languaget &language=*lf.language; @@ -94,8 +93,7 @@ goto_modelt initialize_goto_model( if(language.parse(infile, filename)) { - msg.error() << "PARSING ERROR" << messaget::eom; - throw 0; + throw invalid_source_file_exceptiont("PARSING ERROR"); } lf.get_modules(); @@ -105,8 +103,7 @@ goto_modelt initialize_goto_model( if(language_files.typecheck(goto_model.symbol_table)) { - msg.error() << "CONVERSION ERROR" << messaget::eom; - throw 0; + throw invalid_source_file_exceptiont("CONVERSION ERROR"); } } @@ -115,7 +112,10 @@ goto_modelt initialize_goto_model( msg.status() << "Reading GOTO program from file" << messaget::eom; if(read_object_and_link(file, goto_model, message_handler)) - throw 0; + { + throw invalid_source_file_exceptiont( + "failed to read object or link in file `" + file + '\''); + } } bool binaries_provided_start= @@ -150,14 +150,12 @@ goto_modelt initialize_goto_model( if(entry_point_generation_failed) { - msg.error() << "SUPPORT FUNCTION GENERATION ERROR" << messaget::eom; - throw 0; + throw invalid_source_file_exceptiont("SUPPORT FUNCTION GENERATION ERROR"); } if(language_files.final(goto_model.symbol_table)) { - msg.error() << "FINAL STAGE CONVERSION ERROR" << messaget::eom; - throw 0; + throw invalid_source_file_exceptiont("FINAL STAGE CONVERSION ERROR"); } msg.status() << "Generating GOTO Program" << messaget::eom;