Commit eadaf06f authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Set what string in Error::SetMessage

`vtkm::cont::Error` inherits from `std::exception`. As such, it has a
special `what` string that reports an error message in a standard way.
This is particularly useful when a `vtkm::cont::Error` exception remains
uncaught because the system will print the `what` string before

Unfortunately, the `what` string was only being set in the `Error`
constructor that took a message. That is a problem for subclasses like
`ErrorCuda` that used the default constructor and then used
`SetMessage`. The `what` string did not get set in this case.

Change the behavior to capture the stack trace in the default
constructor and update the `what` string if a subclass uses
parent 210ca76c
......@@ -56,7 +56,12 @@ public:
bool GetIsDeviceIndependent() const { return this->IsDeviceIndependent; }
Error() {}
: StackTrace(vtkm::cont::GetStackTrace(1))
, What("Undescribed error\n" + StackTrace)
, IsDeviceIndependent(false)
Error(const std::string& message, bool is_device_independent = false)
: Message(message)
, StackTrace(vtkm::cont::GetStackTrace(1))
......@@ -65,7 +70,11 @@ protected:
void SetMessage(const std::string& message) { this->Message = message; }
void SetMessage(const std::string& message)
this->Message = message;
this->What = this->Message + "\n" + this->StackTrace;
std::string Message;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment