From 3b22b584f341c06059bcffc3c3d78c390e6c93a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 17 Oct 2016 13:02:50 +0200 Subject: [PATCH] Add OPM_THROW_NOLOG macro. --- opm/common/ErrorMacros.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/opm/common/ErrorMacros.hpp b/opm/common/ErrorMacros.hpp index 8b3f89a33..56ded99cc 100644 --- a/opm/common/ErrorMacros.hpp +++ b/opm/common/ErrorMacros.hpp @@ -57,6 +57,16 @@ throw Exception(oss__.str()); \ } while (false) +// Same as OPM_THROW, except for not making an OpmLog::error() call. +// +// Usage: OPM_THROW_NOLOG(ExceptionClass, "Error message " << value); +#define OPM_THROW_NOLOG(Exception, message) \ + do { \ + std::ostringstream oss__; \ + oss__ << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \ + throw Exception(oss__.str()); \ + } while (false) + // throw an exception if a condition is true #define OPM_ERROR_IF(condition, message) do {if(condition){ OPM_THROW(std::logic_error, message);}} while(false)