# HG changeset patch # User Sebastien Jodogne # Date 1411055335 -7200 # Node ID 0561f2087cc90bcd2e4f031ec21f3f15376c8777 # Parent 0a55d8eb194e7d37b0ea254859e9d2ff150daf6c Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities diff -r 0a55d8eb194e -r 0561f2087cc9 AUTHORS --- a/AUTHORS Thu Sep 18 17:18:26 2014 +0200 +++ b/AUTHORS Thu Sep 18 17:48:55 2014 +0200 @@ -8,7 +8,7 @@ * Sebastien Jodogne Department of Medical Physics, CHU of Liege, Belgium - Overall design and main developper. + Overall design and lead developer. Client library diff -r 0a55d8eb194e -r 0561f2087cc9 Core/RestApi/RestApiOutput.cpp --- a/Core/RestApi/RestApiOutput.cpp Thu Sep 18 17:18:26 2014 +0200 +++ b/Core/RestApi/RestApiOutput.cpp Thu Sep 18 17:48:55 2014 +0200 @@ -129,6 +129,7 @@ void RestApiOutput::SignalError(HttpStatus status) { if (status != HttpStatus_403_Forbidden && + status != HttpStatus_500_InternalServerError && status != HttpStatus_415_UnsupportedMediaType) { throw OrthancException("This HTTP status is not allowed in a REST API"); diff -r 0a55d8eb194e -r 0561f2087cc9 NEWS --- a/NEWS Thu Sep 18 17:18:26 2014 +0200 +++ b/NEWS Thu Sep 18 17:48:55 2014 +0200 @@ -2,6 +2,7 @@ =============================== * Configuration/Lua to select the accepted C-Store SCP transfer syntaxes +* Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities * Installation of plugin SDK in CMake diff -r 0a55d8eb194e -r 0561f2087cc9 OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Thu Sep 18 17:18:26 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Thu Sep 18 17:48:55 2014 +0200 @@ -80,12 +80,17 @@ { if (locker.GetConnection().Echo()) { + // Echo has succeeded call.GetOutput().AnswerBuffer("{}", "application/json"); + return; } } catch (OrthancException&) { } + + // Echo has failed + call.GetOutput().SignalError(HttpStatus_500_InternalServerError); } @@ -357,13 +362,20 @@ for (std::list::const_iterator it = instances.begin(); it != instances.end(); ++it) { - job.AddCommand(new StoreScuCommand(context, p)).AddInput(*it); + job.AddCommand(new StoreScuCommand(context, p, false)).AddInput(*it); } job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\""); - context.GetScheduler().SubmitAndWait(job); - call.GetOutput().AnswerBuffer("{}", "application/json"); + if (context.GetScheduler().SubmitAndWait(job)) + { + // Success + call.GetOutput().AnswerBuffer("{}", "application/json"); + } + else + { + call.GetOutput().SignalError(HttpStatus_500_InternalServerError); + } } @@ -421,13 +433,20 @@ for (std::list::const_iterator it = instances.begin(); it != instances.end(); ++it) { - job.AddCommand(new StorePeerCommand(context, peer)).AddInput(*it); + job.AddCommand(new StorePeerCommand(context, peer, false)).AddInput(*it); } job.SetDescription("HTTP request: POST to peer \"" + remote + "\""); - context.GetScheduler().SubmitAndWait(job); - call.GetOutput().AnswerBuffer("{}", "application/json"); + if (context.GetScheduler().SubmitAndWait(job)) + { + // Success + call.GetOutput().AnswerBuffer("{}", "application/json"); + } + else + { + call.GetOutput().SignalError(HttpStatus_500_InternalServerError); + } } diff -r 0a55d8eb194e -r 0561f2087cc9 OrthancServer/Scheduler/StorePeerCommand.cpp --- a/OrthancServer/Scheduler/StorePeerCommand.cpp Thu Sep 18 17:18:26 2014 +0200 +++ b/OrthancServer/Scheduler/StorePeerCommand.cpp Thu Sep 18 17:48:55 2014 +0200 @@ -39,9 +39,11 @@ namespace Orthanc { StorePeerCommand::StorePeerCommand(ServerContext& context, - const OrthancPeerParameters& peer) : + const OrthancPeerParameters& peer, + bool ignoreExceptions) : context_(context), - peer_(peer) + peer_(peer), + ignoreExceptions_(ignoreExceptions) { } @@ -84,6 +86,11 @@ { LOG(ERROR) << "Unable to forward to an Orthanc peer in a Lua script (instance " << *it << ", peer " << peer_.GetUrl() << "): " << e.What(); + + if (!ignoreExceptions_) + { + throw; + } } } diff -r 0a55d8eb194e -r 0561f2087cc9 OrthancServer/Scheduler/StorePeerCommand.h --- a/OrthancServer/Scheduler/StorePeerCommand.h Thu Sep 18 17:18:26 2014 +0200 +++ b/OrthancServer/Scheduler/StorePeerCommand.h Thu Sep 18 17:48:55 2014 +0200 @@ -43,10 +43,12 @@ private: ServerContext& context_; OrthancPeerParameters peer_; + bool ignoreExceptions_; public: StorePeerCommand(ServerContext& context, - const OrthancPeerParameters& peer); + const OrthancPeerParameters& peer, + bool ignoreExceptions); virtual bool Apply(ListOfStrings& outputs, const ListOfStrings& inputs); diff -r 0a55d8eb194e -r 0561f2087cc9 OrthancServer/Scheduler/StoreScuCommand.cpp --- a/OrthancServer/Scheduler/StoreScuCommand.cpp Thu Sep 18 17:18:26 2014 +0200 +++ b/OrthancServer/Scheduler/StoreScuCommand.cpp Thu Sep 18 17:48:55 2014 +0200 @@ -37,9 +37,11 @@ namespace Orthanc { StoreScuCommand::StoreScuCommand(ServerContext& context, - const RemoteModalityParameters& modality) : + const RemoteModalityParameters& modality, + bool ignoreExceptions) : context_(context), - modality_(modality) + modality_(modality), + ignoreExceptions_(ignoreExceptions) { } @@ -69,6 +71,11 @@ // powered off) LOG(ERROR) << "Unable to forward to a modality in a Lua script (instance " << *it << "): " << e.What(); + + if (!ignoreExceptions_) + { + throw; + } } } diff -r 0a55d8eb194e -r 0561f2087cc9 OrthancServer/Scheduler/StoreScuCommand.h --- a/OrthancServer/Scheduler/StoreScuCommand.h Thu Sep 18 17:18:26 2014 +0200 +++ b/OrthancServer/Scheduler/StoreScuCommand.h Thu Sep 18 17:48:55 2014 +0200 @@ -42,10 +42,12 @@ private: ServerContext& context_; RemoteModalityParameters modality_; + bool ignoreExceptions_; public: StoreScuCommand(ServerContext& context, - const RemoteModalityParameters& modality); + const RemoteModalityParameters& modality, + bool ignoreExceptions); virtual bool Apply(ListOfStrings& outputs, const ListOfStrings& inputs); diff -r 0a55d8eb194e -r 0561f2087cc9 OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Thu Sep 18 17:18:26 2014 +0200 +++ b/OrthancServer/ServerContext.cpp Thu Sep 18 17:48:55 2014 +0200 @@ -138,7 +138,7 @@ std::string modality = parameters["Modality"].asString(); LOG(INFO) << "Lua script to send instance " << parameters["Instance"].asString() << " to modality " << modality << " using Store-SCU"; - return new StoreScuCommand(context, Configuration::GetModalityUsingSymbolicName(modality)); + return new StoreScuCommand(context, Configuration::GetModalityUsingSymbolicName(modality), true); } if (operation == "store-peer") @@ -149,7 +149,7 @@ OrthancPeerParameters parameters; Configuration::GetOrthancPeer(parameters, peer); - return new StorePeerCommand(context, parameters); + return new StorePeerCommand(context, parameters, true); } if (operation == "modify")