mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 13:47:12 -05:00
Refactor RifFormationNamesReader to return std::expected
Replace the QString* errorMessage out-parameter with std::expected<RigFormationNames, QString> in RifFormationNamesReader, and propagate the pattern to RimFormationNames::readFormationNamesFile() which now returns std::expected<void, QString>. Fatal errors (file cannot be opened, FMU line-parse failure) return std::unexpected. Malformed .lyr lines are still skipped so the rest of the file loads, with warnings logged via RiaLogging instead of collected in the out-parameter. RimFormationNamesCollection::readAllFormationNames() now logs errors it previously discarded.
This commit is contained in:
@@ -46,7 +46,10 @@ void RimFormationNamesCollection::readAllFormationNames()
|
||||
{
|
||||
for ( RimFormationNames* fmNames : m_formationNamesList )
|
||||
{
|
||||
fmNames->readFormationNamesFile( nullptr );
|
||||
if ( auto result = fmNames->readFormationNamesFile(); !result )
|
||||
{
|
||||
RiaLogging::error( result.error().toStdString() );
|
||||
}
|
||||
RimProject::current()->colorLegendCollection->createColorLegendFromFormationNames( fmNames );
|
||||
}
|
||||
}
|
||||
@@ -90,12 +93,9 @@ std::vector<RimFormationNames*> RimFormationNamesCollection::importFiles( const
|
||||
|
||||
for ( RimFormationNames* fmNames : formNamesObjsToReload )
|
||||
{
|
||||
QString errormessage;
|
||||
|
||||
fmNames->readFormationNamesFile( &errormessage );
|
||||
if ( !errormessage.isEmpty() )
|
||||
if ( auto result = fmNames->readFormationNamesFile(); !result )
|
||||
{
|
||||
totalErrorMessage += "\nError in: " + fmNames->fileName() + "\n\t" + errormessage;
|
||||
totalErrorMessage += "\nError in: " + fmNames->fileName() + "\n\t" + result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user