mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4429 Implement return status handling for command file interface
This commit is contained in:
@@ -39,7 +39,8 @@ bool RicEclipseCellResultToFileImpl::writePropertyToTextFile(const QString&
|
||||
size_t timeStep,
|
||||
const QString& resultName,
|
||||
const QString& eclipseKeyword,
|
||||
const double undefinedValue)
|
||||
const double undefinedValue,
|
||||
QString* errorMsg)
|
||||
{
|
||||
CVF_TIGHT_ASSERT(eclipseCase);
|
||||
if (!eclipseCase) return false;
|
||||
@@ -52,7 +53,7 @@ bool RicEclipseCellResultToFileImpl::writePropertyToTextFile(const QString&
|
||||
}
|
||||
|
||||
return writeResultToTextFile(
|
||||
fileName, eclipseCase, resultAccessor.p(), eclipseKeyword, undefinedValue, "writePropertyToTextFile");
|
||||
fileName, eclipseCase, resultAccessor.p(), eclipseKeyword, undefinedValue, "writePropertyToTextFile", errorMsg);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -64,7 +65,8 @@ bool RicEclipseCellResultToFileImpl::writeBinaryResultToTextFile(const QString&
|
||||
RimEclipseResultDefinition* resultDefinition,
|
||||
const QString& eclipseKeyword,
|
||||
const double undefinedValue,
|
||||
const QString& logPrefix)
|
||||
const QString& logPrefix,
|
||||
QString* errorMsg)
|
||||
{
|
||||
CVF_TIGHT_ASSERT(eclipseCase);
|
||||
|
||||
@@ -75,7 +77,7 @@ bool RicEclipseCellResultToFileImpl::writeBinaryResultToTextFile(const QString&
|
||||
return false;
|
||||
}
|
||||
|
||||
return writeResultToTextFile(fileName, eclipseCase, resultAccessor.p(), eclipseKeyword, undefinedValue, logPrefix);
|
||||
return writeResultToTextFile(fileName, eclipseCase, resultAccessor.p(), eclipseKeyword, undefinedValue, logPrefix, errorMsg);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -86,18 +88,21 @@ bool RicEclipseCellResultToFileImpl::writeResultToTextFile(const QString& f
|
||||
RigResultAccessor* resultAccessor,
|
||||
const QString& eclipseKeyword,
|
||||
const double undefinedValue,
|
||||
const QString& logPrefix)
|
||||
const QString& logPrefix,
|
||||
QString* errorMsg)
|
||||
{
|
||||
CAF_ASSERT(errorMsg != nullptr);
|
||||
|
||||
if (!resultAccessor)
|
||||
{
|
||||
RiaLogging::error(logPrefix + QString(" : : Could not access result data for '%1'").arg(fileName));
|
||||
*errorMsg = QString(logPrefix + QString(" : : Could not access result data for '%1'").arg(fileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
RiaLogging::error(logPrefix + QString(" : Could not open file '%1'. Do the folder exist?").arg(fileName));
|
||||
*errorMsg = QString(logPrefix + QString(" : Could not open file '%1'. Do the folder exist?").arg(fileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public:
|
||||
size_t timeStep,
|
||||
const QString& resultName,
|
||||
const QString& eclipseKeyword,
|
||||
const double undefinedValue);
|
||||
const double undefinedValue,
|
||||
QString* errorMsg);
|
||||
|
||||
static bool writeBinaryResultToTextFile(const QString& fileName,
|
||||
RigEclipseCaseData* eclipseCase,
|
||||
@@ -47,14 +48,16 @@ public:
|
||||
RimEclipseResultDefinition* resultDefinition,
|
||||
const QString& eclipseKeyword,
|
||||
const double undefinedValue,
|
||||
const QString& logPrefix);
|
||||
const QString& logPrefix,
|
||||
QString* errorMsg);
|
||||
|
||||
static bool writeResultToTextFile(const QString& fileName,
|
||||
RigEclipseCaseData* eclipseCase,
|
||||
RigResultAccessor* resultAccessor,
|
||||
const QString& eclipseKeyword,
|
||||
const double undefinedValue,
|
||||
const QString& logPrefix);
|
||||
const QString& logPrefix,
|
||||
QString* errorMsg);
|
||||
|
||||
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyword, const std::vector<double>& resultData);
|
||||
};
|
||||
|
||||
@@ -107,20 +107,26 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
const double undefinedValue = 0.0;
|
||||
|
||||
bool isOk = RicEclipseCellResultToFileImpl::writePropertyToTextFile(exportSettings.fileName,
|
||||
QString errorMsg;
|
||||
bool isOk = RicEclipseCellResultToFileImpl::writePropertyToTextFile(exportSettings.fileName,
|
||||
inputReservoir->eclipseCaseData(),
|
||||
0,
|
||||
inputProperty->resultName,
|
||||
exportSettings.eclipseKeyword,
|
||||
undefinedValue);
|
||||
undefinedValue,
|
||||
&errorMsg);
|
||||
if (isOk)
|
||||
{
|
||||
inputProperty->fileName = exportSettings.fileName;
|
||||
inputProperty->fileName = exportSettings.fileName;
|
||||
inputProperty->eclipseKeyword = exportSettings.eclipseKeyword;
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
|
||||
inputProperty->updateConnectedEditors();
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaLogging::error(errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,10 +97,12 @@ void RicSaveEclipseResultAsInputPropertyExec::redo()
|
||||
{
|
||||
size_t timeStep = m_cellColors->reservoirView()->currentTimeStep();
|
||||
|
||||
bool isOk = RicEclipseCellResultToFileImpl::writeBinaryResultToTextFile(exportSettings.fileName, m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData(), timeStep, m_cellColors, exportSettings.eclipseKeyword, exportSettings.undefinedValue, "saveEclipseResultAsInputPropertyExec");
|
||||
QString errMsg;
|
||||
bool isOk = RicEclipseCellResultToFileImpl::writeBinaryResultToTextFile(exportSettings.fileName, m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData(), timeStep, m_cellColors, exportSettings.eclipseKeyword, exportSettings.undefinedValue, "saveEclipseResultAsInputPropertyExec", &errMsg);
|
||||
if (!isOk)
|
||||
{
|
||||
RiaLogging::error("Failed to exported current result to " + exportSettings.fileName);
|
||||
QString fullError = QString("Failed to exported current result to %1. Error was: %2").arg(exportSettings.fileName).arg(errMsg);
|
||||
RiaLogging::error(fullError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user