From 8b14d92f10a641bb5f096a2b3767808b998448e6 Mon Sep 17 00:00:00 2001 From: HanzZ Date: Sun, 8 Apr 2012 14:17:32 +0200 Subject: [PATCH] Don't crash when there are duplicated options and print error message instead --- src/config.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 816e6fba..a1c19273 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -193,8 +193,13 @@ bool Config::load(std::istream &ifs) { } bool Config::load(const std::string &configfile, const std::string &jid) { - options_description opts("Transport options"); - return load(configfile, opts, jid); + try { + options_description opts("Transport options"); + return load(configfile, opts, jid); + } catch ( const boost::program_options::multiple_occurrences& e ) { + std::cerr << configfile << " parsing error: " << e.what() << " from option: " << e.get_option_name() << std::endl; + return false; + } } bool Config::reload() {