#include "config/configurationoptions.h"
using namespace std;
+using boost::program_options::invalid_option_value;
using boost::program_options::options_description;
using boost::program_options::parsed_options;
using boost::program_options::parse_config_file;
*/
bool ConfigurationFile::process( variables_map *vm )
{
+ BOOST_ASSERT( !FileName.empty() );
BOOST_ASSERT( vm != NULL );
- ifstream ifs( FileName.c_str() );
- if ( !ifs )
- {
- GlobalLogger.error() << "Error: could not open " << FileName
- << " file." << endl;
- return false;
- }
+ ifstream ifs;
try
{
+ ifs.open( FileName.c_str() );
+ if ( !ifs.good() )
+ {
+ GlobalLogger.error() << "Error: could not open " << FileName
+ << " file." << endl;
+ return false;
+ }
+
ConfigurationOptions options;
options_description config = options.get_configuration_options();
store( parsed_opt, *vm );
notify( *vm );
}
- catch ( const std::exception &ex )
+ catch ( const invalid_option_value &e )
+ {
+ GlobalLogger.error() << "Error: invalid option value exception thrown parsing config file:"
+ << e.what() << endl;
+ return false;
+ }
+ catch ( const exception &ex )
{
GlobalLogger.error() << ex.what() << endl;
return false;
}
+ catch ( ... )
+ {
+ GlobalLogger.error() << "Unknown exception" << endl;
+ return false;
+ }
return true;
}