From d146ada59210f74b8cb60de2dbb354c1dc07cabb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 9 Jun 2022 11:01:27 +0200 Subject: [PATCH] #9037 RFT import: Missing data in RFT file caused crash --- .../FileInterface/RifReaderOpmRft.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp index b73840b077..81db96f123 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp @@ -42,6 +42,10 @@ RifReaderOpmRft::RifReaderOpmRft( const QString& fileName ) buildMetaData(); } + catch ( const std::exception& e ) + { + RiaLogging::error( QString( "Failed to open RFT file %1\n%2" ).arg( fileName ).arg( e.what() ) ); + } catch ( ... ) { RiaLogging::error( QString( "Failed to open RFT file %1" ).arg( fileName ) ); @@ -445,9 +449,16 @@ void RifReaderOpmRft::importWellNames() std::vector RifReaderOpmRft::importWellData( const std::string& wellName, const std::string& propertyName, const RftDate& date ) const { - if ( m_opm_rft->hasArray( propertyName, wellName, date ) ) + try + { + // THe hasArray method can throw, so we must use a try/catch block here + if ( m_opm_rft->hasArray( propertyName, wellName, date ) ) + { + return m_opm_rft->getRft( propertyName, wellName, date ); + } + } + catch ( ... ) { - return m_opm_rft->getRft( propertyName, wellName, date ); } return {};