OpmFlowDeck: avoid swallowing error messages when loading deck.

This commit is contained in:
Kristian Bendiksen authored and JJ committed 2026-03-16 12:53:49 +01:00
1 parent b0153081fc
commit 1f42f70d26
6 files changed
+35 -26

No files matched your search

@@ -40,6 +40,7 @@
#include "opm/input/eclipse/Parser/ParserKeywords/W.hpp"
#include <cmath>
#include <expected>
#include <format>
#include <memory>
#include <optional>
@@ -241,7 +242,7 @@ RifOpmFlowDeckFile::~RifOpmFlowDeckFile()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifOpmFlowDeckFile::loadDeck( std::string filename )
std::expected<void, std::string> RifOpmFlowDeckFile::loadDeck( std::string filename )
{
Opm::ErrorGuard errors{};
@@ -254,14 +255,14 @@ bool RifOpmFlowDeckFile::loadDeck( std::string filename )
splitDatesIfNecessary();
}
catch ( ... )
catch ( const std::exception& e )
{
m_deck.reset();
m_fileDeck.reset();
return false;
return std::unexpected( std::string( e.what() ) + " " + errors.formattedErrors() );
}
return true;
return {};
}
//--------------------------------------------------------------------------------------------------
@@ -19,6 +19,7 @@
#pragma once
#include <ctime>
#include <expected>
#include <memory>
#include <optional>
#include <set>
@@ -46,9 +47,9 @@ public:
RifOpmFlowDeckFile();
~RifOpmFlowDeckFile();
bool loadDeck( std::string filename );
bool saveDeck( std::string folder, std::string filename );
bool saveDeckInline( std::string folder, std::string filename );
std::expected<void, std::string> loadDeck( std::string filename );
bool saveDeck( std::string folder, std::string filename );
bool saveDeckInline( std::string folder, std::string filename );
int mergeKeywordAtPosition( int deckPosition, const Opm::DeckKeyword& keyword );
bool mergeKeywordAtTimeStep( int timeStep, const Opm::DeckKeyword& keyword, std::string insertAfterKeyword = "" );