diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-12-01 21:26:58 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-12-01 21:26:58 +0900 |
| commit | f0f4f8f703b8c927fe8008daecb2d0547d486973 (patch) | |
| tree | aa9f93e55f375f342cc72fb62b5d1cca240c07be /src/option_processing.cc | |
| parent | 6bc215fcec22d8bdf760c78cc25cb8798266c8a5 (diff) | |
Added more error code values.
I have not set error code for all exception invocation.
In this change, I set error code where error likely occurs.
Diffstat (limited to 'src/option_processing.cc')
| -rw-r--r-- | src/option_processing.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/option_processing.cc b/src/option_processing.cc index bb5ef3be..c7e74206 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -145,11 +145,11 @@ void option_processing(Option& op, std::vector<std::string>& uris, << oparser.findByName(e.getOptionName())->getDescription() << std::endl; } - exit(error_code::UNKNOWN_ERROR); + exit(e.getErrorCode()); } catch(Exception& e) { std::cerr << "Parse error in " << cfname << "\n" << e.stackTrace() << std::endl; - exit(error_code::UNKNOWN_ERROR); + exit(e.getErrorCode()); } } else if(!ucfname.empty()) { std::cerr << fmt("Configuration file %s is not found.", cfname.c_str()) @@ -171,15 +171,18 @@ void option_processing(Option& op, std::vector<std::string>& uris, // finaly let's parse and store command-iine options. oparser.parse(op, cmdstream); } catch(OptionHandlerException& e) { - std::cerr << e.stackTrace() << "\n" - << "Usage:" << "\n" - << *oparser.findByName(e.getOptionName()) - << std::endl; - exit(error_code::UNKNOWN_ERROR); + std::cerr << e.stackTrace() << "\n"; + SharedHandle<OptionHandler> h = oparser.findByName(e.getOptionName()); + if(h) { + std::cerr << "Usage:" << "\n" + << *h + << std::endl; + } + exit(e.getErrorCode()); } catch(Exception& e) { std::cerr << e.stackTrace() << std::endl; showUsage(TAG_HELP, oparser); - exit(error_code::UNKNOWN_ERROR); + exit(e.getErrorCode()); } if( #ifdef ENABLE_XML_RPC |
