summaryrefslogtreecommitdiff
path: root/src/Context.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-05-02 10:03:00 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-05-02 10:03:00 +0900
commitaee621b3d40a270d827f5d3441dfccec66705ca9 (patch)
treec27eec43a940c2489dedb2aa550842873815e4fd /src/Context.cc
parente5cccd335cc99f28615d44d5cb0b4400239c63cd (diff)
Don't exit on error in option_processing
Still it exits when -v or -h is given. They are now guarded by standalone variable and only do so when it is true.
Diffstat (limited to 'src/Context.cc')
-rw-r--r--src/Context.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Context.cc b/src/Context.cc
index 7543a28f..81022e24 100644
--- a/src/Context.cc
+++ b/src/Context.cc
@@ -175,17 +175,25 @@ void showFiles
} // namespace
#endif // ENABLE_BITTORRENT || ENABLE_METALINK
-extern void option_processing(Option& option, bool standalone,
- std::vector<std::string>& uris,
- int argc, char** argv, const KeyVals& options);
+extern error_code::Value option_processing(Option& option, bool standalone,
+ std::vector<std::string>& uris,
+ int argc, char** argv,
+ const KeyVals& options);
Context::Context(bool standalone,
int argc, char** argv, const KeyVals& options)
{
std::vector<std::string> args;
SharedHandle<Option> op(new Option());
- option_processing(*op.get(), standalone, args, argc, argv, options);
-
+ error_code::Value rv;
+ rv = option_processing(*op.get(), standalone, args, argc, argv, options);
+ if(rv != error_code::FINISHED) {
+ if(standalone) {
+ exit(rv);
+ } else {
+ throw DL_ABORT_EX("Option processing failed");
+ }
+ }
SimpleRandomizer::init();
#ifdef ENABLE_BITTORRENT
bittorrent::generateStaticPeerId(op->get(PREF_PEER_ID_PREFIX));