mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-09 23:53:04 -06:00
(#515) Handling exceptions from NRLib
Returning error message string picked from exception when trying to read a file, if any.
This commit is contained in:
parent
5d18209e26
commit
f15c9973c9
@ -25,6 +25,8 @@
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <exception>
|
||||
|
||||
#define RIG_WELL_FOOTPERMETER 3.2808399
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -48,15 +50,35 @@ RigWellLogFile::~RigWellLogFile()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigWellLogFile::open(const QString& fileName)
|
||||
bool RigWellLogFile::open(const QString& fileName, QString* errorMessage)
|
||||
{
|
||||
close();
|
||||
|
||||
int wellFormat = NRLib::Well::LAS;
|
||||
NRLib::Well* well = NRLib::Well::ReadWell(fileName.toStdString(), wellFormat);
|
||||
if (!well)
|
||||
NRLib::Well* well = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
// TODO: Error handling
|
||||
int wellFormat = NRLib::Well::LAS;
|
||||
well = NRLib::Well::ReadWell(fileName.toStdString(), wellFormat);
|
||||
if (!well)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
if (well)
|
||||
{
|
||||
delete well;
|
||||
}
|
||||
|
||||
if (e.what())
|
||||
{
|
||||
CVF_ASSERT(errorMessage);
|
||||
*errorMessage = e.what();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
RigWellLogFile();
|
||||
virtual ~RigWellLogFile();
|
||||
|
||||
bool open(const QString& fileName);
|
||||
bool open(const QString& fileName, QString* errorMessage);
|
||||
|
||||
QString wellName() const;
|
||||
QStringList wellLogChannelNames() const;
|
||||
|
Loading…
Reference in New Issue
Block a user