mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-24 23:36:50 -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 <QString>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#define RIG_WELL_FOOTPERMETER 3.2808399
|
#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();
|
close();
|
||||||
|
|
||||||
int wellFormat = NRLib::Well::LAS;
|
int wellFormat = NRLib::Well::LAS;
|
||||||
NRLib::Well* well = NRLib::Well::ReadWell(fileName.toStdString(), wellFormat);
|
NRLib::Well* well = NULL;
|
||||||
if (!well)
|
|
||||||
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
RigWellLogFile();
|
RigWellLogFile();
|
||||||
virtual ~RigWellLogFile();
|
virtual ~RigWellLogFile();
|
||||||
|
|
||||||
bool open(const QString& fileName);
|
bool open(const QString& fileName, QString* errorMessage);
|
||||||
|
|
||||||
QString wellName() const;
|
QString wellName() const;
|
||||||
QStringList wellLogChannelNames() const;
|
QStringList wellLogChannelNames() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user