Skip to content

Commit

Permalink
Throw exception if category string is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 10, 2025
1 parent c74bf57 commit e5b6ded
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,15 @@ std::string RiuSummaryQuantityNameInfoProvider::stringFromEnum( RifEclipseSummar
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddressDefines::SummaryCategory RiuSummaryQuantityNameInfoProvider::enumFromString( const std::string& category )
{
return caf::AppEnum<RifEclipseSummaryAddressDefines::SummaryCategory>::fromText( QString::fromStdString( category ) );
auto qstring = QString::fromStdString( category );

auto valid = caf::AppEnum<RifEclipseSummaryAddressDefines::SummaryCategory>::isValid( qstring );
if ( !valid )
{
// The category strings in keywords*.json must be mapped to the enum values in the enum definition
// Ensure that the strings in the json file are correct in /ApplicationLibCode/Application/Resources/keyword-description
throw std::runtime_error( "Invalid category string: " + category );
}

return caf::AppEnum<RifEclipseSummaryAddressDefines::SummaryCategory>::fromText( qstring );
}

0 comments on commit e5b6ded

Please sign in to comment.