From 83b60bd68dee00e6801091e1d7b9727a557e2e4c Mon Sep 17 00:00:00 2001 From: Bjoern Sikora Date: Tue, 28 Jul 2009 12:53:05 +0200 Subject: [PATCH] Error handling for unknown service. --- src/config.cpp | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 71742c9..4b3fa8c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -91,7 +91,11 @@ const int Config::parse_cmd_line(int argc, char *argv[]) //TODO: convert protocol option to lowercase - Services.push_back(create_service(protocol,host,login,password)); + ServicePtr service = create_service(protocol,host,login,password); + if ( service != NULL ) + { + Services.push_back(service); + } } else { @@ -130,7 +134,9 @@ ServicePtr Config::create_service(const string &protocol,const string &host, con } else { - // TODO: error handling for unknown protocol + cout << "Could not find specified protocol: " << protocol << endl; + ServicePtr service; + return service; } } @@ -209,7 +215,19 @@ const int Config::load_config_from_files(const string& config_path) if(vm.count("service.protocol") && vm.count("service.host") && vm.count("service.login") && vm.count("service.password")) { // create the corresponding service - Services.push_back(create_service(vm["service.protocol"].as(),vm["service.host"].as(),vm["service.login"].as(),vm["service.password"].as())); + string protocol = vm["service.protocol"].as(); + string host = vm["service.host"].as(); + string login = vm["service.login"].as(); + string password = vm["service.password"].as(); + + // TODO: convert protocol to lowercase + protocol = tolower(protocol.c_str()); + + ServicePtr service = create_service(protocol,host,login,password); + if ( service != NULL ) + { + Services.push_back(service); + } } } catch ( po::unknown_option e ) -- 1.7.1