Mercurial > hg > orthanc
diff OrthancServer/Scheduler/StorePeerCommand.cpp @ 1099:060e8918d7a4
More fault-tolerant commands in Lua scripts
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Aug 2014 10:02:22 +0200 |
parents | 871c49c9b11d |
children | 0561f2087cc9 |
line wrap: on
line diff
--- a/OrthancServer/Scheduler/StorePeerCommand.cpp Tue Aug 05 16:18:45 2014 +0200 +++ b/OrthancServer/Scheduler/StorePeerCommand.cpp Thu Aug 07 10:02:22 2014 +0200 @@ -66,16 +66,25 @@ LOG(INFO) << "Sending resource " << *it << " to peer \"" << peer_.GetUrl() << "\""; - context_.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom); - - std::string answer; - if (!client.Apply(answer)) + try { - LOG(ERROR) << "Unable to send resource " << *it << " to peer \"" << peer_.GetUrl() << "\""; - throw OrthancException(ErrorCode_NetworkProtocol); + context_.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom); + + std::string answer; + if (!client.Apply(answer)) + { + LOG(ERROR) << "Unable to send resource " << *it << " to peer \"" << peer_.GetUrl() << "\""; + throw OrthancException(ErrorCode_NetworkProtocol); + } + + // Only chain with other commands if this command succeeds + outputs.push_back(*it); } - - outputs.push_back(*it); + catch (OrthancException& e) + { + LOG(ERROR) << "Unable to forward to an Orthanc peer in a Lua script (instance " + << *it << ", peer " << peer_.GetUrl() << "): " << e.What(); + } } return true;