From c974e9d7524e698db383e1538c6dad6bdaada970 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Thu, 27 Apr 2017 00:36:02 +0200 Subject: [PATCH] Exception: Add CADKernelError exception for specialized OCC exception propagation to App::DocumentObject --- src/Base/Exception.cpp | 17 +++++++++++++++++ src/Base/Exception.h | 19 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Base/Exception.cpp b/src/Base/Exception.cpp index d01a4dd0c8..3bd34efab9 100644 --- a/src/Base/Exception.cpp +++ b/src/Base/Exception.cpp @@ -545,6 +545,23 @@ UnitsMismatchError::UnitsMismatchError(const UnitsMismatchError &inst) { } +// --------------------------------------------------------- + +CADKernelError::CADKernelError(const char * sMessage) +: Exception(sMessage) +{ +} + +CADKernelError::CADKernelError(const std::string& sMessage) +: Exception(sMessage) +{ +} + +CADKernelError::CADKernelError(const CADKernelError &inst) +: Exception(inst) +{ +} + // --------------------------------------------------------- #if defined(__GNUC__) && defined (FC_OS_LINUX) diff --git a/src/Base/Exception.h b/src/Base/Exception.h index 8dbdb24a2b..4deccee075 100644 --- a/src/Base/Exception.h +++ b/src/Base/Exception.h @@ -55,7 +55,7 @@ public: // FIXME: Remove the public keyword Exception(const std::string& sMessage); Exception(void); Exception(const Exception &inst); - + protected: std::string _sErrMsg; }; @@ -488,6 +488,23 @@ public: virtual ~UnitsMismatchError() throw() {} }; + /* The CADKernelError can be used to indicate an exception originating in the CAD Kernel + * allowing to propagate the error messages of, for example, OCC Standard_Failure exception to + * the FreeCAD application without making the FreeCAD application depend on OCC. + * @author Abdullah Tahiri + */ +class BaseExport CADKernelError : public Exception +{ +public: + /// Construction + CADKernelError(const char * sMessage); + CADKernelError(const std::string& sMessage); + /// Construction + CADKernelError(const CADKernelError &inst); + /// Destruction + virtual ~CADKernelError() throw() {} +}; + inline void Exception::setMessage(const char * sMessage) {