# HG changeset patch # User Sebastien Jodogne # Date 1481896519 -3600 # Node ID 319b8c45c2310eb02c82425b937805878f258d8b # Parent 8a20cd67b2839b30b049feb98b153afde922e04f sync diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/DicomDatasetReader.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/DicomDatasetReader.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/DicomDatasetReader.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -32,7 +32,7 @@ #include "DicomDatasetReader.h" -#include "OrthancPluginCppWrapper.h" +#include "OrthancPluginException.h" #include @@ -73,7 +73,7 @@ { if (dataset == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -87,7 +87,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InexistentTag); + ORTHANC_PLUGINS_THROW_EXCEPTION(InexistentTag); } } @@ -101,7 +101,7 @@ } catch (boost::bad_lexical_cast&) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } @@ -116,7 +116,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } } diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/DicomPath.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/DicomPath.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/DicomPath.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -32,7 +32,7 @@ #include "DicomPath.h" -#include "OrthancPluginCppWrapper.h" +#include "OrthancPluginException.h" namespace OrthancPlugins { @@ -40,7 +40,7 @@ { if (depth >= prefix_.size()) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } else { diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/DicomTag.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/DicomTag.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/DicomTag.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -32,7 +32,7 @@ #include "DicomTag.h" -#include "OrthancPluginCppWrapper.h" +#include "OrthancPluginException.h" namespace OrthancPlugins { @@ -104,7 +104,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_NotImplemented); + ORTHANC_PLUGINS_THROW_EXCEPTION(NotImplemented); } } } diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -32,7 +32,10 @@ #include "FullOrthancDataset.h" -#include "OrthancPluginCppWrapper.h" +#include "OrthancPluginException.h" + +#include +#include namespace OrthancPlugins { @@ -41,7 +44,7 @@ { if (dataset.type() != Json::objectValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } char name[16]; @@ -60,7 +63,7 @@ value["Name"].type() != Json::stringValue || value["Type"].type() != Json::stringValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } return &value; @@ -78,7 +81,7 @@ if (sequence["Type"].asString() != "Sequence" || value.type() != Json::arrayValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } else { @@ -99,7 +102,7 @@ if (tag["Type"].asString() != "String" || value.type() != Json::stringValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } else { @@ -142,7 +145,7 @@ { if (root_.type() != Json::objectValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/IOrthancConnection.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -32,7 +32,7 @@ #include "IOrthancConnection.h" -#include "OrthancPluginCppWrapper.h" +#include "OrthancPluginException.h" #include @@ -45,7 +45,7 @@ if (!reader.parse(content, result)) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/OrthancPluginConnection.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginConnection.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginConnection.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -47,7 +47,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource); + ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); } } @@ -64,7 +64,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource); + ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); } } @@ -81,7 +81,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource); + ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); } } @@ -92,7 +92,7 @@ if (!::OrthancPlugins::RestApiDelete(context_, uri, false)) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource); + ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); } } } diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -38,32 +38,6 @@ namespace OrthancPlugins { - const char* GetErrorDescription(OrthancPluginContext* context, - OrthancPluginErrorCode code) - { - const char* description = OrthancPluginGetErrorDescription(context, code); - if (description) - { - return description; - } - else - { - return "No description available"; - } - } - - -#if HAS_ORTHANC_EXCEPTION == 0 - void PluginException::Check(OrthancPluginErrorCode code) - { - if (code != OrthancPluginErrorCode_Success) - { - ORTHANC_PLUGINS_THROW_EXCEPTION(code); - } - } -#endif - - void MemoryBuffer::Check(OrthancPluginErrorCode code) { if (code != OrthancPluginErrorCode_Success) @@ -71,7 +45,7 @@ // Prevent using garbage information buffer_.data = NULL; buffer_.size = 0; - ORTHANC_PLUGINS_THROW_EXCEPTION(code); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); } } @@ -125,7 +99,7 @@ if (buffer_.data == NULL || buffer_.size == 0) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } const char* tmp = reinterpret_cast(buffer_.data); @@ -134,7 +108,7 @@ if (!reader.parse(tmp, tmp + buffer_.size, target)) { OrthancPluginLogError(context_, "Cannot convert some memory buffer to JSON"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } @@ -166,7 +140,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(error); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(error); } } @@ -200,7 +174,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(error); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(error); } } @@ -234,7 +208,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(error); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(error); } } @@ -287,7 +261,7 @@ { if (str == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } else { @@ -325,14 +299,14 @@ if (str_ == NULL) { OrthancPluginLogError(context_, "Cannot convert an empty memory buffer to JSON"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } Json::Reader reader; if (!reader.parse(str_, target)) { OrthancPluginLogError(context_, "Cannot convert some memory buffer to JSON"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } @@ -358,7 +332,7 @@ if (str.GetContent() == NULL) { OrthancPluginLogError(context, "Cannot access the Orthanc configuration"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } str.ToJson(configuration_); @@ -366,7 +340,7 @@ if (configuration_.type() != Json::objectValue) { OrthancPluginLogError(context, "Unable to read the Orthanc configuration"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } } @@ -375,7 +349,7 @@ { if (context_ == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_Plugin); + ORTHANC_PLUGINS_THROW_EXCEPTION(Plugin); } else { @@ -428,7 +402,7 @@ OrthancPluginLogError(context_, s.c_str()); } - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } target.configuration_ = configuration_[key]; @@ -454,7 +428,7 @@ OrthancPluginLogError(context_, s.c_str()); } - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } target = configuration_[key].asString(); @@ -489,7 +463,7 @@ OrthancPluginLogError(context_, s.c_str()); } - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } @@ -511,7 +485,7 @@ OrthancPluginLogError(context_, s.c_str()); } - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } else { @@ -539,7 +513,7 @@ OrthancPluginLogError(context_, s.c_str()); } - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } target = configuration_[key].asBool(); @@ -578,7 +552,7 @@ OrthancPluginLogError(context_, s.c_str()); } - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } @@ -673,7 +647,7 @@ if (image_ == NULL) { OrthancPluginLogError(context_, "Trying to access a NULL image"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -684,7 +658,7 @@ { if (context == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -696,7 +670,7 @@ { if (context == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -709,7 +683,7 @@ { if (context == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } else { @@ -726,7 +700,7 @@ if (image_ == NULL) { OrthancPluginLogError(context_, "Cannot uncompress a PNG image"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -739,7 +713,7 @@ if (image_ == NULL) { OrthancPluginLogError(context_, "Cannot uncompress a JPEG image"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -753,7 +727,7 @@ if (image_ == NULL) { OrthancPluginLogError(context_, "Cannot uncompress a DICOM image"); - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -845,7 +819,7 @@ { if (worklist_ == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); + ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); } } @@ -860,7 +834,7 @@ matcher_ = OrthancPluginCreateFindMatcher(context_, query, size); if (matcher_ == NULL) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } } @@ -892,7 +866,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } if (result == 0) @@ -905,7 +879,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); } } @@ -1018,7 +992,7 @@ } else { - ORTHANC_PLUGINS_THROW_EXCEPTION(error); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(error); } } diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h --- a/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h Fri Dec 16 14:55:19 2016 +0100 @@ -32,23 +32,13 @@ #pragma once +#include "OrthancPluginException.h" + #include #include #include #include -#if !defined(HAS_ORTHANC_EXCEPTION) -# error The macro HAS_ORTHANC_EXCEPTION must be defined -#endif - - -#if HAS_ORTHANC_EXCEPTION == 1 -# include "../../../Core/OrthancException.h" -# define ORTHANC_PLUGINS_THROW_EXCEPTION(code) throw ::Orthanc::OrthancException(static_cast(code)) -#else -# define ORTHANC_PLUGINS_THROW_EXCEPTION(code) throw ::OrthancPlugins::PluginException(code) -#endif - #if (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER >= 2 || \ (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == 1 && \ @@ -61,42 +51,12 @@ - namespace OrthancPlugins { typedef void (*RestCallback) (OrthancPluginRestOutput* output, const char* url, const OrthancPluginHttpRequest* request); - const char* GetErrorDescription(OrthancPluginContext* context, - OrthancPluginErrorCode code); - -#if HAS_ORTHANC_EXCEPTION == 0 - class PluginException - { - private: - OrthancPluginErrorCode code_; - - public: - PluginException(OrthancPluginErrorCode code) : code_(code) - { - } - - OrthancPluginErrorCode GetErrorCode() const - { - return code_; - } - - const char* What(OrthancPluginContext* context) const - { - return ::OrthancPlugins::GetErrorDescription(context, code_); - } - - static void Check(OrthancPluginErrorCode code); - }; -#endif - - class MemoryBuffer : public boost::noncopyable { private: @@ -487,17 +447,10 @@ Callback(output, url, request); return OrthancPluginErrorCode_Success; } -#if HAS_ORTHANC_EXCEPTION == 1 - catch (Orthanc::OrthancException& e) + catch (ORTHANC_PLUGINS_GET_EXCEPTION_CLASS& e) { return static_cast(e.GetErrorCode()); } -#else - catch (OrthancPlugins::PluginException& e) - { - return e.GetErrorCode(); - } -#endif catch (boost::bad_lexical_cast&) { return OrthancPluginErrorCode_BadFileFormat; diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/OrthancPluginException.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginException.h Fri Dec 16 14:55:19 2016 +0100 @@ -0,0 +1,100 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#if !defined(HAS_ORTHANC_EXCEPTION) +# error The macro HAS_ORTHANC_EXCEPTION must be defined +#endif + + +#if HAS_ORTHANC_EXCEPTION == 1 +# include "../../../Core/OrthancException.h" +# define ORTHANC_PLUGINS_GET_ERROR_ENUMERATION ::Orthanc::ErrorCode +# define ORTHANC_PLUGINS_GET_ERROR_CODE(code) ::Orthanc::ErrorCode_ ## code +# define ORTHANC_PLUGINS_GET_EXCEPTION_CLASS ::Orthanc::OrthancException +#else +# include +# define ORTHANC_PLUGINS_GET_ERROR_ENUMERATION ::OrthancPluginErrorCode +# define ORTHANC_PLUGINS_GET_ERROR_CODE(code) ::OrthancPluginErrorCode_ ## code +# define ORTHANC_PLUGINS_GET_EXCEPTION_CLASS ::OrthancPlugins::PluginException +#endif + + +#define ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code) \ + throw ORTHANC_PLUGINS_GET_EXCEPTION_CLASS(static_cast(code)); + + +#define ORTHANC_PLUGINS_THROW_EXCEPTION(code) \ + throw ORTHANC_PLUGINS_GET_EXCEPTION_CLASS(ORTHANC_PLUGINS_GET_ERROR_CODE(code)); + + +#define ORTHANC_PLUGINS_CHECK_ERROR(code) \ + if (code != ORTHANC_PLUGINS_GET_ERROR_CODE(Success)) \ + { \ + ORTHANC_PLUGINS_THROW_EXCEPTION(code); \ + } + + +namespace OrthancPlugins +{ +#if HAS_ORTHANC_EXCEPTION == 0 + class PluginException + { + private: + OrthancPluginErrorCode code_; + + public: + explicit PluginException(OrthancPluginErrorCode code) : code_(code) + { + } + + OrthancPluginErrorCode GetErrorCode() const + { + return code_; + } + + const char* What(OrthancPluginContext* context) const + { + const char* description = OrthancPluginGetErrorDescription(context, code_); + if (description) + { + return description; + } + else + { + return "No description available"; + } + } + }; +#endif +} diff -r 8a20cd67b283 -r 319b8c45c231 Resources/Orthanc/Plugins/Samples/Common/SimplifiedOrthancDataset.cpp --- a/Resources/Orthanc/Plugins/Samples/Common/SimplifiedOrthancDataset.cpp Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/Orthanc/Plugins/Samples/Common/SimplifiedOrthancDataset.cpp Fri Dec 16 14:55:19 2016 +0100 @@ -32,7 +32,7 @@ #include "SimplifiedOrthancDataset.h" -#include "OrthancPluginCppWrapper.h" +#include "OrthancPluginException.h" namespace OrthancPlugins { @@ -45,7 +45,7 @@ const char* name = path.GetPrefixTag(depth).GetName(); if (content->type() != Json::objectValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } if (!content->isMember(name)) @@ -56,7 +56,7 @@ const Json::Value& sequence = (*content) [name]; if (sequence.type() != Json::arrayValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } size_t index = path.GetPrefixIndex(depth); @@ -74,7 +74,7 @@ if (content->type() != Json::objectValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } if (!content->isMember(name)) { @@ -91,7 +91,7 @@ { if (root_.type() != Json::objectValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } } @@ -122,7 +122,7 @@ } else if (value->type() != Json::stringValue) { - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } else { @@ -145,7 +145,7 @@ else if (sequence->type() != Json::arrayValue) { // Not a sequence - ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); + ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); } else { diff -r 8a20cd67b283 -r 319b8c45c231 Resources/SyncOrthancFolder.py --- a/Resources/SyncOrthancFolder.py Thu Dec 15 15:37:40 2016 +0100 +++ b/Resources/SyncOrthancFolder.py Fri Dec 16 14:55:19 2016 +0100 @@ -87,6 +87,7 @@ 'Plugins/Samples/Common/ExportedSymbols.list', 'Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins/Samples/Common/OrthancPluginCppWrapper.h', + 'Plugins/Samples/Common/OrthancPluginException.h', 'Plugins/Samples/Common/VersionScript.map', 'Plugins/Samples/Common/DicomDatasetReader.cpp', 'Plugins/Samples/Common/DicomDatasetReader.h',