Inherit std::exception in vtkm::cont::Error.

Fixes #58.
This commit is contained in:
David C. Lonie 2017-01-09 15:34:35 -05:00
parent 589285eb5e
commit 4a9b8b6f77
2 changed files with 12 additions and 1 deletions

@ -24,14 +24,17 @@
// templated. If there is any reason to create a VTKm control library,
// this class and its subclasses should probably go there.
#include <exception>
#include <string>
#include <vtkm/internal/ExportMacros.h> // For VTKM_OVERRIDE
namespace vtkm {
namespace cont {
/// The superclass of all exceptions thrown by any VTKm function or method.
///
class Error
class Error : public std::exception
{
public:
//See note about GetMessage macro below.
@ -47,6 +50,12 @@ public:
const std::string &GetMessageW() const { return this->Message; }
#endif
// For std::exception compatibility:
const char* what() const VTKM_NOEXCEPT VTKM_OVERRIDE
{
return this->Message.c_str();
}
protected:
Error() { }
Error(const std::string message) : Message(message) { }

@ -48,8 +48,10 @@
// sure when that we gracefully fall back to just const when using 2013
#if defined(VTKM_MSVC) && _MSC_VER < 1900
#define VTKM_CONSTEXPR const
#define VTKM_NOEXCEPT
#else
#define VTKM_CONSTEXPR constexpr
#define VTKM_NOEXCEPT noexcept
#endif
#define VTKM_OVERRIDE override