Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 2960:74a5a7fd6e0e
log flag to OrthancPluginSetHttpErrorDetails
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Dec 2018 18:56:39 +0100 |
parents | ccf61f6e22ef |
children | db8f360fcb41 |
comparison
equal
deleted
inserted
replaced
2959:7364415851ac | 2960:74a5a7fd6e0e |
---|---|
322 class PluginHttpOutput : public boost::noncopyable | 322 class PluginHttpOutput : public boost::noncopyable |
323 { | 323 { |
324 private: | 324 private: |
325 HttpOutput& output_; | 325 HttpOutput& output_; |
326 std::auto_ptr<std::string> errorDetails_; | 326 std::auto_ptr<std::string> errorDetails_; |
327 bool logDetails_; | |
327 | 328 |
328 public: | 329 public: |
329 PluginHttpOutput(HttpOutput& output) : | 330 PluginHttpOutput(HttpOutput& output) : |
330 output_(output) | 331 output_(output), |
332 logDetails_(false) | |
331 { | 333 { |
332 } | 334 } |
333 | 335 |
334 HttpOutput& GetOutput() | 336 HttpOutput& GetOutput() |
335 { | 337 { |
336 return output_; | 338 return output_; |
337 } | 339 } |
338 | 340 |
339 void SetErrorDetails(const std::string& details) | 341 void SetErrorDetails(const std::string& details, |
342 bool logDetails) | |
340 { | 343 { |
341 errorDetails_.reset(new std::string(details)); | 344 errorDetails_.reset(new std::string(details)); |
345 logDetails_ = logDetails; | |
342 } | 346 } |
343 | 347 |
344 bool HasErrorDetails() const | 348 bool HasErrorDetails() const |
345 { | 349 { |
346 return errorDetails_.get() != NULL; | 350 return errorDetails_.get() != NULL; |
351 } | |
352 | |
353 bool IsLogDetails() const | |
354 { | |
355 return logDetails_; | |
347 } | 356 } |
348 | 357 |
349 const std::string& GetErrorDetails() const | 358 const std::string& GetErrorDetails() const |
350 { | 359 { |
351 if (errorDetails_.get() == NULL) | 360 if (errorDetails_.get() == NULL) |
1067 | 1076 |
1068 assert(callback != NULL); | 1077 assert(callback != NULL); |
1069 | 1078 |
1070 PImpl::PluginHttpOutput pluginOutput(output); | 1079 PImpl::PluginHttpOutput pluginOutput(output); |
1071 | 1080 |
1072 OrthancPluginErrorCode error = callback->Invoke(pimpl_->restCallbackMutex_, pluginOutput, flatUri, request); | 1081 OrthancPluginErrorCode error = callback->Invoke |
1082 (pimpl_->restCallbackMutex_, pluginOutput, flatUri, request); | |
1073 | 1083 |
1074 if (error == OrthancPluginErrorCode_Success && | 1084 if (error == OrthancPluginErrorCode_Success && |
1075 output.IsWritingMultipart()) | 1085 output.IsWritingMultipart()) |
1076 { | 1086 { |
1077 output.CloseMultipart(); | 1087 output.CloseMultipart(); |
1085 { | 1095 { |
1086 GetErrorDictionary().LogError(error, false); | 1096 GetErrorDictionary().LogError(error, false); |
1087 | 1097 |
1088 if (pluginOutput.HasErrorDetails()) | 1098 if (pluginOutput.HasErrorDetails()) |
1089 { | 1099 { |
1090 throw OrthancException(static_cast<ErrorCode>(error), pluginOutput.GetErrorDetails()); | 1100 throw OrthancException(static_cast<ErrorCode>(error), |
1101 pluginOutput.GetErrorDetails(), | |
1102 pluginOutput.IsLogDetails()); | |
1091 } | 1103 } |
1092 else | 1104 else |
1093 { | 1105 { |
1094 throw OrthancException(static_cast<ErrorCode>(error)); | 1106 throw OrthancException(static_cast<ErrorCode>(error)); |
1095 } | 1107 } |
1387 void OrthancPlugins::SetHttpErrorDetails(const void* parameters) | 1399 void OrthancPlugins::SetHttpErrorDetails(const void* parameters) |
1388 { | 1400 { |
1389 const _OrthancPluginSetHttpErrorDetails& p = | 1401 const _OrthancPluginSetHttpErrorDetails& p = |
1390 *reinterpret_cast<const _OrthancPluginSetHttpErrorDetails*>(parameters); | 1402 *reinterpret_cast<const _OrthancPluginSetHttpErrorDetails*>(parameters); |
1391 | 1403 |
1392 PImpl::PluginHttpOutput* output = reinterpret_cast<PImpl::PluginHttpOutput*>(p.output); | 1404 PImpl::PluginHttpOutput* output = |
1393 output->SetErrorDetails(p.details); | 1405 reinterpret_cast<PImpl::PluginHttpOutput*>(p.output); |
1406 output->SetErrorDetails(p.details, p.log); | |
1394 } | 1407 } |
1395 | 1408 |
1396 | 1409 |
1397 void OrthancPlugins::CompressAndAnswerPngImage(const void* parameters) | 1410 void OrthancPlugins::CompressAndAnswerPngImage(const void* parameters) |
1398 { | 1411 { |