From 325c75fd70834416c17545a977a295728b0284d8 Mon Sep 17 00:00:00 2001 From: nadavi Date: Wed, 4 Sep 2019 13:03:30 -0600 Subject: [PATCH] store What as a member var --- vtkm/cont/Error.h | 8 +++----- vtkm/cont/testing/UnitTestError.cxx | 5 +---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/vtkm/cont/Error.h b/vtkm/cont/Error.h index 18201df07..15e56e44d 100644 --- a/vtkm/cont/Error.h +++ b/vtkm/cont/Error.h @@ -48,11 +48,7 @@ public: #endif // For std::exception compatibility: - const char* what() const noexcept override - { - std::string tmp = this->Message + "\n" + this->StackTrace; - return tmp.c_str(); - } + const char* what() const noexcept override { return this->What.c_str(); } /// Returns true if this exception is device independent. For exceptions that /// are not device independent, `vtkm::TryExecute`, for example, may try @@ -64,6 +60,7 @@ protected: Error(const std::string& message, bool is_device_independent = false) : Message(message) , StackTrace(vtkm::cont::GetStackTrace(1)) + , What(Message + "\n" + StackTrace) , IsDeviceIndependent(is_device_independent) { } @@ -73,6 +70,7 @@ protected: private: std::string Message; std::string StackTrace; + std::string What; bool IsDeviceIndependent; }; diff --git a/vtkm/cont/testing/UnitTestError.cxx b/vtkm/cont/testing/UnitTestError.cxx index a401ff420..6e518ac93 100644 --- a/vtkm/cont/testing/UnitTestError.cxx +++ b/vtkm/cont/testing/UnitTestError.cxx @@ -51,16 +51,13 @@ void ValidateError(const vtkm::cont::Error& error) VTKM_TEST_ASSERT(count > 11, "StackTrace did not recurse enough"); } VTKM_TEST_ASSERT(test_equal(message, error.GetMessage()), "Message was incorrect"); - std::string k = error.what(); - std::cout << "what directly:" << error.what() << std::endl; - std::cout << "what as var: " << k << std::endl; VTKM_TEST_ASSERT(test_equal(message + "\n" + stackTrace, std::string(error.what())), "what() was incorrect"); } void DoErrorTest() { - VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Check base error mesgs"); + VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Check base error messages"); try { RecursiveFunction(0);