mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add and use OPM_DEFLOG_PROBLEM macro.
This should replace OPM_DEFLOG_THROW in places where the problem category is more appropriate than the error category. In this commit, uses of OPM_DEFLOG_THROW have been replaced whenever the exception class used was NumericalProblem.
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
||||
// Macro to throw an exception.
|
||||
// Macro to log an error and throw an exception.
|
||||
// Inspired by ErrorMacros.hpp in opm-common.
|
||||
// NOTE: For this macro to work, the
|
||||
// exception class must exhibit a constructor with the signature
|
||||
@@ -51,6 +51,23 @@
|
||||
throw Exception(oss_); \
|
||||
} while (false)
|
||||
|
||||
// Macro to log a problem and throw an exception.
|
||||
// Idenitical to OPM_DEFLOG_THROW() except for using
|
||||
// the "problem" category instead of "error" for the
|
||||
// log message. The Exception argument will typically
|
||||
// be NumericalProblem.
|
||||
//
|
||||
// Usage: OPM_DEFLOG_PROBLEM(ExceptionClass, "Error message", DeferredLogger);
|
||||
#define OPM_DEFLOG_PROBLEM(Exception, message, deferred_logger) \
|
||||
do { \
|
||||
std::string oss_ = std::string{"["} + __FILE__ + ":" + \
|
||||
std::to_string(__LINE__) + "] " + \
|
||||
message; \
|
||||
deferred_logger.problem(oss_); \
|
||||
throw Exception(oss_); \
|
||||
} while (false)
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void _throw(Opm::ExceptionType::ExcEnum exc_type,
|
||||
|
||||
Reference in New Issue
Block a user