From 78b629767ff2fda2f3a79c6a2036a9ac9ea0de1e Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Wed, 28 Jun 2023 15:11:37 +0200 Subject: [PATCH] [refactor] Use limits and OPM_THROW when checking max equil regions. that will ease changing the limits and the error will appear in all logs. --- ebos/eclgenericthresholdpressure.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ebos/eclgenericthresholdpressure.cc b/ebos/eclgenericthresholdpressure.cc index a0a6331a3..cf9963dc4 100644 --- a/ebos/eclgenericthresholdpressure.cc +++ b/ebos/eclgenericthresholdpressure.cc @@ -22,6 +22,7 @@ */ #include +#include #include #include @@ -120,10 +121,16 @@ finishInit() return; numEquilRegions_ = eclState_.getTableManager().getEqldims().getNumEquilRegions(); - if (numEquilRegions_ > 0xff) { + const decltype(numEquilRegions_) maxRegions = + std::numeric_limits>::max(); + + if (numEquilRegions_ > maxRegions) { // make sure that the index of an equilibration region can be stored in a // single byte - throw std::runtime_error("The maximum number of supported equilibration regions is 255!"); + OPM_THROW(std::invalid_argument, + (fmt::format("The maximum number of supported " + "equilibration regions by OPM flow is {}!", + maxRegions))); } // internalize the data specified using the EQLNUM keyword