Convert assert() to throw

Convert assert() to throw to be consistent with usage elsewhere in
the code base where external interface violations should cause
thrown exceptions instead of causing assertion failures which will
not even be enforced in release builds.
This commit is contained in:
Håkon Hægland committed 2025-11-27 14:17:29 +01:00
1 parent f9cfbf0c68
commit 5be44f3802
1 file changed
+5 -1
+5 -1
View File
@@ -311,7 +311,11 @@ namespace Opm
if (!fixed_control) {
// When solving_with_zero_rate=true, fixed_control=true, so this block should never
// be entered.
assert(!solving_with_zero_rate);
if (solving_with_zero_rate) {
OPM_DEFLOG_THROW(std::runtime_error, fmt::format(
"Well {}: solving_with_zero_rate should not be true when fixed_control is false",
this->name()), deferred_logger);
}
// Changing to group controls here may lead to inconsistencies in the group handling which in turn
// may result in excessive back and forth switching. However, we currently allow this by default.