Mercurial > hg > orthanc-wsi
diff Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 86:319b8c45c231
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Dec 2016 14:55:19 +0100 |
parents | 5b127ab0080b |
children | 7dffa59c498d |
line wrap: on
line diff
--- 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 <orthanc/OrthancCPlugin.h> #include <boost/noncopyable.hpp> #include <boost/lexical_cast.hpp> #include <json/value.h> -#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<Orthanc::ErrorCode>(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<OrthancPluginErrorCode>(e.GetErrorCode()); } -#else - catch (OrthancPlugins::PluginException& e) - { - return e.GetErrorCode(); - } -#endif catch (boost::bad_lexical_cast&) { return OrthancPluginErrorCode_BadFileFormat;