From 135695fcb5f99768cd63fbf2ade6785a38d4181f Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 7 May 2025 11:34:59 +0200 Subject: [PATCH] #5556 Refactor python error handling. --- .../CommandRouter/RimcExtractSurfaces.cpp | 2 +- .../CommandRouter/RimcExtractSurfaces.h | 2 +- .../RimcEclipseCase.cpp | 2 +- .../RimcEclipseCase.h | 8 +-- .../RimcEclipseStatisticsCase.cpp | 6 +-- .../RimcEclipseStatisticsCase.h | 24 ++++----- .../RimcElasticProperties.cpp | 2 +- .../RimcElasticProperties.h | 6 +-- .../RimcFishbonesCollection.cpp | 6 +-- .../RimcFishbonesCollection.h | 18 +++---- .../RimcFractureTemplate.cpp | 2 +- .../RimcFractureTemplate.h | 8 +-- .../RimcFractureTemplateCollection.cpp | 4 +- .../RimcFractureTemplateCollection.h | 12 ++--- .../RimcIdenticalGridCaseGroup.cpp | 2 +- .../RimcIdenticalGridCaseGroup.h | 6 +-- .../RimcIntersection.cpp | 4 +- .../RimcIntersection.h | 12 ++--- .../RimcModeledWellPath.cpp | 2 +- .../RimcModeledWellPath.h | 6 +-- .../RimcPolygonCollection.cpp | 2 +- .../RimcPolygonCollection.h | 6 +-- .../RimcPressureTable.cpp | 2 +- .../RimcPressureTable.h | 6 +-- .../ProjectDataModelCommands/RimcProject.cpp | 8 +-- .../ProjectDataModelCommands/RimcProject.h | 32 ++++++------ .../RimcStimPlanModel.cpp | 9 ++-- .../RimcStimPlanModel.h | 8 +-- .../RimcStimPlanModelCollection.cpp | 2 +- .../RimcStimPlanModelCollection.h | 6 +-- .../RimcStimPlanModelPlotCollection.cpp | 2 +- .../RimcStimPlanModelPlotCollection.h | 6 +-- .../RimcStimPlanModelTemplateCollection.cpp | 2 +- .../RimcStimPlanModelTemplateCollection.h | 6 +-- .../RimcSummaryCase.cpp | 10 ++-- .../RimcSummaryCase.h | 32 ++++++------ .../RimcSummaryPlotCollection.cpp | 2 +- .../RimcSummaryPlotCollection.h | 6 +-- .../ProjectDataModelCommands/RimcSurface.cpp | 2 +- .../ProjectDataModelCommands/RimcSurface.h | 8 +-- .../RimcSurfaceCollection.cpp | 6 +-- .../RimcSurfaceCollection.h | 24 ++++----- .../RimcThermalFractureTemplate.cpp | 4 +- .../RimcThermalFractureTemplate.h | 16 +++--- .../RimcWellLogPlot.cpp | 2 +- .../RimcWellLogPlot.h | 6 +-- .../RimcWellLogPlotCollection.cpp | 2 +- .../RimcWellLogPlotCollection.h | 6 +-- .../RimcWellLogTrack.cpp | 2 +- .../RimcWellLogTrack.h | 6 +-- .../ProjectDataModelCommands/RimcWellPath.cpp | 10 ++-- .../ProjectDataModelCommands/RimcWellPath.h | 34 ++++++------- .../RimcWellPathGeometryDef.cpp | 2 +- .../RimcWellPathGeometryDef.h | 6 +-- Fwk/AppFwk/CMakeLists.txt | 2 +- .../cafPdmScripting/cafPdmObjectMethod.h | 4 +- .../cafPdmObjectMethodTest.cpp | 10 ++-- Fwk/CMakeLists.txt | 2 +- GrpcInterface/CMakeLists.txt | 2 +- .../rips/PythonExamples/error_handling.py | 19 +++---- GrpcInterface/Python/rips/__init__.py | 1 + GrpcInterface/Python/rips/exception.py | 2 + GrpcInterface/Python/rips/pdmobject.py | 49 +++++++++++++------ GrpcInterface/Python/rips/tests/test_cases.py | 2 +- .../Python/rips/tests/test_nnc_properties.py | 4 +- .../Python/rips/tests/test_pdmobject.py | 16 ++++++ .../Python/rips/tests/test_properties.py | 2 +- .../rips/tests/test_wells_path_completions.py | 1 - GrpcInterface/RiaGrpcPdmObjectService.cpp | 34 ++++++++----- 69 files changed, 307 insertions(+), 260 deletions(-) create mode 100644 GrpcInterface/Python/rips/exception.py create mode 100644 GrpcInterface/Python/rips/tests/test_pdmobject.py diff --git a/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp b/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp index 7feea3638b..6259fde7ea 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.cpp @@ -54,7 +54,7 @@ RimcCommandRouter_extractSurfaces::RimcCommandRouter_extractSurfaces( caf::PdmOb //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcCommandRouter_extractSurfaces::execute() +std::expected RimcCommandRouter_extractSurfaces::execute() { extractSurfaces( m_gridModelFilename, m_layers(), m_minimumI(), m_maximumI(), m_minimumJ(), m_maximumJ() ); return nullptr; diff --git a/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.h b/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.h index 5a9b368bf5..ca9925bd8c 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.h +++ b/ApplicationLibCode/ProjectDataModelCommands/CommandRouter/RimcExtractSurfaces.h @@ -39,7 +39,7 @@ class RimcCommandRouter_extractSurfaces : public RimCommandRouterMethod public: RimcCommandRouter_extractSurfaces( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; + std::expected execute() override; static bool readMinMaxLayerFromGridFile( const QString& gridFileName, int& minK, int& maxK ); static std::pair extractSurfaces( const QString& gridModelFileName, diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp index a30c5f3d42..d22a2ea663 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp @@ -53,7 +53,7 @@ RimcEclipseCase_importProperties::RimcEclipseCase_importProperties( caf::PdmObje //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcEclipseCase_importProperties::execute() +std::expected RimcEclipseCase_importProperties::execute() { std::vector absolutePaths = m_fileNames; for ( auto& path : absolutePaths ) diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.h b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.h index c39a1da412..3f328e49f7 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.h @@ -36,10 +36,10 @@ class RimcEclipseCase_importProperties : public caf::PdmObjectMethod public: RimcEclipseCase_importProperties( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField> m_fileNames; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.cpp index 079edad08f..a5b5c235b2 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.cpp @@ -44,7 +44,7 @@ RimcEclipseStatisticsCase_setSourceProperties::RimcEclipseStatisticsCase_setSour //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcEclipseStatisticsCase_setSourceProperties::execute() +std::expected RimcEclipseStatisticsCase_setSourceProperties::execute() { RiaDefines::ResultCatType myEnum = caf::AppEnum::fromText( m_propertyType() ); @@ -99,7 +99,7 @@ RimcEclipseStatisticsCase_computeStatistics::RimcEclipseStatisticsCase_computeSt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcEclipseStatisticsCase_computeStatistics::execute() +std::expected RimcEclipseStatisticsCase_computeStatistics::execute() { auto eclipseCase = self(); eclipseCase->computeStatistics(); @@ -144,7 +144,7 @@ RimcEclipseStatisticsCase_clearSourceProperties::RimcEclipseStatisticsCase_clear //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcEclipseStatisticsCase_clearSourceProperties::execute() +std::expected RimcEclipseStatisticsCase_clearSourceProperties::execute() { auto myEnums = { RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaDefines::ResultCatType::STATIC_NATIVE, diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.h b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.h index a7bd0bcba4..c769fe164f 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseStatisticsCase.h @@ -36,10 +36,10 @@ class RimcEclipseStatisticsCase_setSourceProperties : public caf::PdmObjectMetho public: RimcEclipseStatisticsCase_setSourceProperties( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_propertyType; @@ -56,10 +56,10 @@ class RimcEclipseStatisticsCase_computeStatistics : public caf::PdmObjectMethod public: RimcEclipseStatisticsCase_computeStatistics( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; }; //================================================================================================== @@ -72,8 +72,8 @@ class RimcEclipseStatisticsCase_clearSourceProperties : public caf::PdmObjectMet public: RimcEclipseStatisticsCase_clearSourceProperties( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; }; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.cpp index 24a47cc18a..39fb800e7c 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.cpp @@ -43,7 +43,7 @@ RimcElasticProperties_addPropertyScaling::RimcElasticProperties_addPropertyScali //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcElasticProperties_addPropertyScaling::execute() +std::expected RimcElasticProperties_addPropertyScaling::execute() { RimElasticProperties* elasticProperties = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.h b/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.h index 6df8ce757f..3c3d088c4e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcElasticProperties.h @@ -41,9 +41,9 @@ class RimcElasticProperties_addPropertyScaling : public caf::PdmObjectMethod public: RimcElasticProperties_addPropertyScaling( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_formation; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.cpp index ffa56dc167..67c79a48a2 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.cpp @@ -44,7 +44,7 @@ RimcFishbonesCollection_appendFishbones::RimcFishbonesCollection_appendFishbones //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcFishbonesCollection_appendFishbones::execute() +std::expected RimcFishbonesCollection_appendFishbones::execute() { auto fishbonesCollection = self(); if ( !fishbonesCollection ) return nullptr; @@ -98,7 +98,7 @@ RimcFishbonesCollection_setFixedStartLocation::RimcFishbonesCollection_setFixedS //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcFishbonesCollection_setFixedStartLocation::execute() +std::expected RimcFishbonesCollection_setFixedStartLocation::execute() { auto fishbonesCollection = self(); if ( fishbonesCollection ) @@ -149,7 +149,7 @@ RimcFishbonesCollection_setFixedEndLocation::RimcFishbonesCollection_setFixedEnd //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcFishbonesCollection_setFixedEndLocation::execute() +std::expected RimcFishbonesCollection_setFixedEndLocation::execute() { auto fishbonesCollection = self(); if ( fishbonesCollection ) diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.h index 56e1b682f9..8087ec0b51 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFishbonesCollection.h @@ -34,9 +34,9 @@ class RimcFishbonesCollection_appendFishbones : public caf::PdmObjectMethod public: RimcFishbonesCollection_appendFishbones( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField> m_subLocations; @@ -53,9 +53,9 @@ class RimcFishbonesCollection_setFixedStartLocation : public caf::PdmObjectMetho public: RimcFishbonesCollection_setFixedStartLocation( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; bool isNullptrValidResult() const override; @@ -73,9 +73,9 @@ class RimcFishbonesCollection_setFixedEndLocation : public caf::PdmObjectMethod public: RimcFishbonesCollection_setFixedEndLocation( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; bool isNullptrValidResult() const override; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.cpp index f54e44bda4..3b11bcd718 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.cpp @@ -42,7 +42,7 @@ RimcFractureTemplate_setScaleFactors::RimcFractureTemplate_setScaleFactors( caf: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcFractureTemplate_setScaleFactors::execute() +std::expected RimcFractureTemplate_setScaleFactors::execute() { if ( m_halfLength() <= 0.0 || m_height() <= 0.0 || m_dFactor() <= 0.0 || m_conductivity() <= 0.0 ) { diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.h b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.h index 373cb788c5..b8d2ad7222 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplate.h @@ -36,10 +36,10 @@ class RimcFractureTemplate_setScaleFactors : public caf::PdmObjectMethod public: RimcFractureTemplate_setScaleFactors( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_halfLength; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp index 4a2431cbcb..b7c309b897 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp @@ -48,7 +48,7 @@ RimcFractureTemplateCollection_appendFractureTemplate::RimcFractureTemplateColle //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcFractureTemplateCollection_appendFractureTemplate::execute() +std::expected RimcFractureTemplateCollection_appendFractureTemplate::execute() { RimFractureTemplateCollection* stimPlanModelTemplateCollection = self(); @@ -95,7 +95,7 @@ RimcFractureTemplateCollection_appendThermalFractureTemplate::RimcFractureTempla //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcFractureTemplateCollection_appendThermalFractureTemplate::execute() +std::expected RimcFractureTemplateCollection_appendThermalFractureTemplate::execute() { RimFractureTemplateCollection* fractureTemplateCollection = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.h index 30ed89b171..1eedf8bfa7 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.h @@ -36,9 +36,9 @@ class RimcFractureTemplateCollection_appendFractureTemplate : public caf::PdmObj public: RimcFractureTemplateCollection_appendFractureTemplate( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_filePath; @@ -54,9 +54,9 @@ class RimcFractureTemplateCollection_appendThermalFractureTemplate : public caf: public: RimcFractureTemplateCollection_appendThermalFractureTemplate( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_filePath; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.cpp index ef4040cbcf..cc54a32157 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.cpp @@ -36,7 +36,7 @@ RimcIdenticalGridCaseGroup_createStatisticsCase::RimcIdenticalGridCaseGroup_crea //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcIdenticalGridCaseGroup_createStatisticsCase::execute() +std::expected RimcIdenticalGridCaseGroup_createStatisticsCase::execute() { auto gridCaseGroup = self(); auto statCase = gridCaseGroup->createAndAppendEmptyStatisticsCase(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.h b/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.h index ec7d5a93e6..3b16324727 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcIdenticalGridCaseGroup.h @@ -36,7 +36,7 @@ class RimcIdenticalGridCaseGroup_createStatisticsCase : public caf::PdmObjectMet public: RimcIdenticalGridCaseGroup_createStatisticsCase( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; }; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.cpp index 406d441101..cc5a865da6 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.cpp @@ -188,7 +188,7 @@ RimcExtrudedCurveIntersection_geometry::RimcExtrudedCurveIntersection_geometry( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcExtrudedCurveIntersection_geometry::execute() +std::expected RimcExtrudedCurveIntersection_geometry::execute() { auto intersection = self(); @@ -297,7 +297,7 @@ RimcExtrudedCurveIntersection_geometryResult::RimcExtrudedCurveIntersection_geom //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcExtrudedCurveIntersection_geometryResult::execute() +std::expected RimcExtrudedCurveIntersection_geometryResult::execute() { auto intersection = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.h index 410a440b9e..226d5cdc2f 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcIntersection.h @@ -86,9 +86,9 @@ class RimcExtrudedCurveIntersection_geometry : public caf::PdmObjectMethod public: RimcExtrudedCurveIntersection_geometry( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; static std::unique_ptr createGeometryGenerator( RimExtrudedCurveIntersection* intersection, RimcTriangleGeometry::GeometryType geometryType ); @@ -107,9 +107,9 @@ class RimcExtrudedCurveIntersection_geometryResult : public caf::PdmObjectMethod public: RimcExtrudedCurveIntersection_geometryResult( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField> m_geometryType; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.cpp index 34534e7202..49ee88ba4e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.cpp @@ -44,7 +44,7 @@ RimcModeledWellPath_appendLateral::RimcModeledWellPath_appendLateral( caf::PdmOb //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcModeledWellPath_appendLateral::execute() +std::expected RimcModeledWellPath_appendLateral::execute() { auto parentWellPath = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.h b/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.h index d34915d824..07b3bc0ec2 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcModeledWellPath.h @@ -36,9 +36,9 @@ class RimcModeledWellPath_appendLateral : public caf::PdmObjectMethod public: RimcModeledWellPath_appendLateral( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_tieInDepth; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.cpp index 058c04cd35..08421365cb 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.cpp @@ -41,7 +41,7 @@ RimcPolygonCollection_createPolygon::RimcPolygonCollection_createPolygon( caf::P //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcPolygonCollection_createPolygon::execute() +std::expected RimcPolygonCollection_createPolygon::execute() { auto polygonCollection = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.h index 6d16a0fb18..dea1475589 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcPolygonCollection.h @@ -36,9 +36,9 @@ class RimcPolygonCollection_createPolygon : public caf::PdmObjectMethod public: RimcPolygonCollection_createPolygon( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_name; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp index b3d3477615..017382b763 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp @@ -41,7 +41,7 @@ RimcPressureTable_addPressure::RimcPressureTable_addPressure( caf::PdmObjectHand //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcPressureTable_addPressure::execute() +std::expected RimcPressureTable_addPressure::execute() { RimPressureTableItem* pressureTableItem = new RimPressureTableItem; pressureTableItem->setValues( m_depth, m_initialPressure, m_pressure ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h index 35d4416c19..728873a7e3 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h @@ -34,9 +34,9 @@ class RimcPressureTable_addPressure : public caf::PdmObjectMethod public: RimcPressureTable_addPressure( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_depth; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp index a1d98d1c3e..cc5ac19805 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcProject.cpp @@ -61,7 +61,7 @@ RimProject_importSummaryCase::RimProject_importSummaryCase( caf::PdmObjectHandle //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimProject_importSummaryCase::execute() +std::expected RimProject_importSummaryCase::execute() { QString absolutePath = m_fileName; QFileInfo projectPathInfo( absolutePath ); @@ -136,7 +136,7 @@ RimProject_summaryCase::RimProject_summaryCase( caf::PdmObjectHandle* self ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimProject_summaryCase::execute() +std::expected RimProject_summaryCase::execute() { auto proj = RimProject::current(); auto sumCases = proj->allSummaryCases(); @@ -188,7 +188,7 @@ RimProject_surfaceFolder::RimProject_surfaceFolder( caf::PdmObjectHandle* self ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimProject_surfaceFolder::execute() +std::expected RimProject_surfaceFolder::execute() { auto proj = RimProject::current(); RimSurfaceCollection* surfcoll = proj->activeOilField()->surfaceCollection(); @@ -252,7 +252,7 @@ RimProject_createGridFromKeyValues::RimProject_createGridFromKeyValues( caf::Pdm //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimProject_createGridFromKeyValues::execute() +std::expected RimProject_createGridFromKeyValues::execute() { RiaLogging::info( "Creating grid from key values" ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcProject.h b/ApplicationLibCode/ProjectDataModelCommands/RimcProject.h index 6d1ebebd80..00fbbc014e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcProject.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcProject.h @@ -36,10 +36,10 @@ class RimProject_importSummaryCase : public caf::PdmObjectMethod public: RimProject_importSummaryCase( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_fileName; @@ -55,10 +55,10 @@ class RimProject_summaryCase : public caf::PdmObjectMethod public: RimProject_summaryCase( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_caseId; @@ -74,10 +74,10 @@ class RimProject_surfaceFolder : public caf::PdmObjectMethod public: RimProject_surfaceFolder( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_folderName; @@ -93,10 +93,10 @@ class RimProject_createGridFromKeyValues : public caf::PdmObjectMethod public: RimProject_createGridFromKeyValues( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_name; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.cpp index 0678ccdf8d..1c1aa67eb3 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.cpp @@ -39,13 +39,14 @@ RimcStimPlanModel_exportToFile::RimcStimPlanModel_exportToFile( caf::PdmObjectHa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcStimPlanModel_exportToFile::execute() +std::expected RimcStimPlanModel_exportToFile::execute() { RimStimPlanModel* stimPlanModel = self(); - RifStimPlanModelExporter::writeToDirectory( stimPlanModel, stimPlanModel->useDetailedFluidLoss(), m_directoryPath() ); - - return nullptr; + if ( RifStimPlanModelExporter::writeToDirectory( stimPlanModel, stimPlanModel->useDetailedFluidLoss(), m_directoryPath() ) ) + return nullptr; + else + return std::unexpected( "Unable to write model to directory" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.h b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.h index 9b343c2257..0990eefd4b 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModel.h @@ -37,10 +37,10 @@ class RimcStimPlanModel_exportToFile : public caf::PdmObjectMethod public: RimcStimPlanModel_exportToFile( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_directoryPath; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp index 56b29242b4..ca1bce4217 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.cpp @@ -48,7 +48,7 @@ RimcStimPlanModelCollection_appendStimPlanModel::RimcStimPlanModelCollection_app //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcStimPlanModelCollection_appendStimPlanModel::execute() +std::expected RimcStimPlanModelCollection_appendStimPlanModel::execute() { RimStimPlanModel* stimPlanModel = nullptr; RimStimPlanModelCollection* stimPlanModelCollection = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.h index 0188ff2a29..13eaaaaf0d 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelCollection.h @@ -42,9 +42,9 @@ class RimcStimPlanModelCollection_appendStimPlanModel : public caf::PdmObjectMet public: RimcStimPlanModelCollection_appendStimPlanModel( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmPtrField m_wellPath; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.cpp index 394510344e..52adc5be71 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.cpp @@ -44,7 +44,7 @@ RimcStimPlanModelPlotCollection_appendStimPlanModelPlot::RimcStimPlanModelPlotCo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcStimPlanModelPlotCollection_appendStimPlanModelPlot::execute() +std::expected RimcStimPlanModelPlotCollection_appendStimPlanModelPlot::execute() { RimStimPlanModelPlot* stimPlanModelPlot = nullptr; RimStimPlanModelPlotCollection* stimPlanModelPlotCollection = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.h index 104470bb1a..8b0f5c8eee 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelPlotCollection.h @@ -37,9 +37,9 @@ class RimcStimPlanModelPlotCollection_appendStimPlanModelPlot : public caf::PdmO public: RimcStimPlanModelPlotCollection_appendStimPlanModelPlot( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmPtrField m_stimPlanModel; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.cpp index 5171490686..f40f523caa 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.cpp @@ -52,7 +52,7 @@ RimcStimPlanModelTemplateCollection_appendStimPlanModelTemplate::RimcStimPlanMod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcStimPlanModelTemplateCollection_appendStimPlanModelTemplate::execute() +std::expected RimcStimPlanModelTemplateCollection_appendStimPlanModelTemplate::execute() { if ( !m_eclipseCase ) return nullptr; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.h index c7b64576f3..57f3609157 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcStimPlanModelTemplateCollection.h @@ -40,9 +40,9 @@ class RimcStimPlanModelTemplateCollection_appendStimPlanModelTemplate : public c public: RimcStimPlanModelTemplateCollection_appendStimPlanModelTemplate( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmPtrField m_eclipseCase; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp index be1e83071a..56148fc783 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.cpp @@ -47,7 +47,7 @@ RimSummaryCase_summaryVectorValues::RimSummaryCase_summaryVectorValues( caf::Pdm //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimSummaryCase_summaryVectorValues::execute() +std::expected RimSummaryCase_summaryVectorValues::execute() { auto* summaryCase = self(); RifSummaryReaderInterface* sumReader = summaryCase->summaryReader(); @@ -96,7 +96,7 @@ RimSummaryCase_availableAddresses::RimSummaryCase_availableAddresses( caf::PdmOb //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimSummaryCase_availableAddresses::execute() +std::expected RimSummaryCase_availableAddresses::execute() { auto* summaryCase = self(); @@ -148,7 +148,7 @@ RimSummaryCase_availableTimeSteps::RimSummaryCase_availableTimeSteps( caf::PdmOb //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimSummaryCase_availableTimeSteps::execute() +std::expected RimSummaryCase_availableTimeSteps::execute() { auto* summaryCase = self(); RifSummaryReaderInterface* sumReader = summaryCase->summaryReader(); @@ -196,7 +196,7 @@ RimSummaryCase_resampleValues::RimSummaryCase_resampleValues( caf::PdmObjectHand //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimSummaryCase_resampleValues::execute() +std::expected RimSummaryCase_resampleValues::execute() { auto* summaryCase = self(); RifSummaryReaderInterface* sumReader = summaryCase->summaryReader(); @@ -269,7 +269,7 @@ RimSummaryCase_setSummaryVectorValues::RimSummaryCase_setSummaryVectorValues( ca //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimSummaryCase_setSummaryVectorValues::execute() +std::expected RimSummaryCase_setSummaryVectorValues::execute() { auto* summaryCase = self(); auto* fileSummaryCase = dynamic_cast( summaryCase ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.h b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.h index 335b4bbb6b..8492bd85f6 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryCase.h @@ -36,9 +36,9 @@ class RimSummaryCase_summaryVectorValues : public caf::PdmObjectMethod public: RimSummaryCase_summaryVectorValues( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_addressString; @@ -54,9 +54,9 @@ class RimSummaryCase_availableAddresses : public caf::PdmObjectMethod public: RimSummaryCase_availableAddresses( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; }; //================================================================================================== @@ -69,9 +69,9 @@ class RimSummaryCase_availableTimeSteps : public caf::PdmObjectMethod public: RimSummaryCase_availableTimeSteps( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; }; //================================================================================================== @@ -84,9 +84,9 @@ class RimSummaryCase_resampleValues : public caf::PdmObjectMethod public: RimSummaryCase_resampleValues( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_addressString; @@ -103,10 +103,10 @@ class RimSummaryCase_setSummaryVectorValues : public caf::PdmObjectMethod public: RimSummaryCase_setSummaryVectorValues( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_addressString; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp index 17dc9a8694..a5b4b9c7e2 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.cpp @@ -52,7 +52,7 @@ RimcSummaryPlotCollection_newSummaryPlot::RimcSummaryPlotCollection_newSummaryPl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcSummaryPlotCollection_newSummaryPlot::execute() +std::expected RimcSummaryPlotCollection_newSummaryPlot::execute() { QStringList addressStrings = RiaTextStringTools::splitSkipEmptyParts( m_addressString(), ";" ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h index 6c50e7b5e7..599637cbde 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSummaryPlotCollection.h @@ -42,9 +42,9 @@ class RimcSummaryPlotCollection_newSummaryPlot : public caf::PdmObjectMethod public: RimcSummaryPlotCollection_newSummaryPlot( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_addressString; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.cpp index 32e3b17ed0..b618621526 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.cpp @@ -45,7 +45,7 @@ RimcSurface_exportToFile::RimcSurface_exportToFile( caf::PdmObjectHandle* self ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcSurface_exportToFile::execute() +std::expected RimcSurface_exportToFile::execute() { RimSurface* surface = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.h b/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.h index a8c9fbff6c..7547f25904 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSurface.h @@ -38,10 +38,10 @@ class RimcSurface_exportToFile : public caf::PdmObjectMethod public: RimcSurface_exportToFile( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_fileName; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp index deaa6f7bd2..539ab3149a 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.cpp @@ -47,7 +47,7 @@ RimcSurfaceCollection_importSurface::RimcSurfaceCollection_importSurface( caf::P //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcSurfaceCollection_importSurface::execute() +std::expected RimcSurfaceCollection_importSurface::execute() { RimSurfaceCollection* coll = self(); if ( coll ) @@ -96,7 +96,7 @@ RimcSurfaceCollection_addFolder::RimcSurfaceCollection_addFolder( caf::PdmObject //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcSurfaceCollection_addFolder::execute() +std::expected RimcSurfaceCollection_addFolder::execute() { RimSurfaceCollection* coll = self(); if ( coll ) @@ -148,7 +148,7 @@ RimcSurfaceCollection_newSurface::RimcSurfaceCollection_newSurface( caf::PdmObje //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcSurfaceCollection_newSurface::execute() +std::expected RimcSurfaceCollection_newSurface::execute() { RimSurfaceCollection* coll = self(); if ( coll && m_case ) diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.h index e46a5ec98e..4625654004 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcSurfaceCollection.h @@ -43,10 +43,10 @@ class RimcSurfaceCollection_importSurface : public caf::PdmObjectMethod public: RimcSurfaceCollection_importSurface( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_fileName; @@ -62,10 +62,10 @@ class RimcSurfaceCollection_addFolder : public caf::PdmObjectMethod public: RimcSurfaceCollection_addFolder( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_folderName; @@ -81,10 +81,10 @@ class RimcSurfaceCollection_newSurface : public caf::PdmObjectMethod public: RimcSurfaceCollection_newSurface( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmPtrField m_case; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.cpp index 6b3cebcf81..976fedb490 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.cpp @@ -42,7 +42,7 @@ RimcThermalFractureTemplate_exportToFile::RimcThermalFractureTemplate_exportToFi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcThermalFractureTemplate_exportToFile::execute() +std::expected RimcThermalFractureTemplate_exportToFile::execute() { RimThermalFractureTemplate* thermalFracture = self(); if ( thermalFracture && thermalFracture->fractureDefinition() ) @@ -88,7 +88,7 @@ RimcThermalFractureTemplate_timeSteps::RimcThermalFractureTemplate_timeSteps( ca //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcThermalFractureTemplate_timeSteps::execute() +std::expected RimcThermalFractureTemplate_timeSteps::execute() { RimThermalFractureTemplate* thermalFracture = self(); auto timeSteps = thermalFracture->timeStepsStrings(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.h b/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.h index 172a2a2dc5..d8db3003a8 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcThermalFractureTemplate.h @@ -37,10 +37,10 @@ class RimcThermalFractureTemplate_exportToFile : public caf::PdmObjectMethod public: RimcThermalFractureTemplate_exportToFile( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; private: caf::PdmField m_filePath; @@ -57,8 +57,8 @@ class RimcThermalFractureTemplate_timeSteps : public caf::PdmObjectMethod public: RimcThermalFractureTemplate_timeSteps( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; - bool isNullptrValidResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + bool isNullptrValidResult() const override; }; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp index 28421983f6..3de91b8b9d 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.cpp @@ -50,7 +50,7 @@ RimcWellLogPlot_newWellLogTrack::RimcWellLogPlot_newWellLogTrack( caf::PdmObject //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellLogPlot_newWellLogTrack::execute() +std::expected RimcWellLogPlot_newWellLogTrack::execute() { RimWellLogPlot* wellLogPlot = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.h index 4575ac198f..087b776e00 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlot.h @@ -39,9 +39,9 @@ class RimcWellLogPlot_newWellLogTrack : public caf::PdmObjectMethod public: RimcWellLogPlot_newWellLogTrack( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; static RimWellLogTrack* createWellLogTrack( RimWellLogPlot* wellLogPlot, RimEclipseCase* eclipseCase, RimWellPath* wellPath, const QString& title ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.cpp index 0674410c58..dda3c949fd 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.cpp @@ -54,7 +54,7 @@ RimcWellLogPlotCollection_newWellLogPlot::RimcWellLogPlotCollection_newWellLogPl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellLogPlotCollection_newWellLogPlot::execute() +std::expected RimcWellLogPlotCollection_newWellLogPlot::execute() { RimWellLogPlot* newWellLogPlot = nullptr; RimWellLogPlotCollection* wellLogPlotCollection = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.h index c9165711da..e985515667 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogPlotCollection.h @@ -37,9 +37,9 @@ class RimcWellLogPlotCollection_newWellLogPlot : public caf::PdmObjectMethod public: RimcWellLogPlotCollection_newWellLogPlot( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; static RimWellLogPlot* createWellLogPlot( RimWellLogPlotCollection* wellLogPlotCollection, RimWellPath* wellPath, RimEclipseCase* eclipseCase ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp index 67631ad614..1a289267f3 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.cpp @@ -53,7 +53,7 @@ RimcWellLogTrack_addExtractionCurve::RimcWellLogTrack_addExtractionCurve( caf::P //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellLogTrack_addExtractionCurve::execute() +std::expected RimcWellLogTrack_addExtractionCurve::execute() { RimWellLogTrack* wellLogTrack = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.h index 4b42821206..29e2837c96 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellLogTrack.h @@ -40,9 +40,9 @@ class RimcWellLogTrack_addExtractionCurve : public caf::PdmObjectMethod public: RimcWellLogTrack_addExtractionCurve( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; static RimWellLogExtractionCurve* addExtractionCurve( RimWellLogTrack* wellLogTrack, RimEclipseCase* eclipseCase, diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp index 0493f5aabb..00be6ff163 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp @@ -64,7 +64,7 @@ RimcWellPath_addFracture::RimcWellPath_addFracture( caf::PdmObjectHandle* self ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellPath_addFracture::execute() +std::expected RimcWellPath_addFracture::execute() { auto wellPath = self(); @@ -141,7 +141,7 @@ RimcWellPath_addThermalFracture::RimcWellPath_addThermalFracture( caf::PdmObject //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellPath_addThermalFracture::execute() +std::expected RimcWellPath_addThermalFracture::execute() { auto wellPath = self(); @@ -194,7 +194,7 @@ RimcWellPath_appendPerforationInterval::RimcWellPath_appendPerforationInterval( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellPath_appendPerforationInterval::execute() +std::expected RimcWellPath_appendPerforationInterval::execute() { auto wellPath = self(); @@ -243,7 +243,7 @@ RimcWellPath_multiSegmentWellSettings::RimcWellPath_multiSegmentWellSettings( ca //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellPath_multiSegmentWellSettings::execute() +std::expected RimcWellPath_multiSegmentWellSettings::execute() { auto wellPath = self(); @@ -303,7 +303,7 @@ RimcWellPath_appendFishbones::RimcWellPath_appendFishbones( caf::PdmObjectHandle //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcWellPath_appendFishbones::execute() +std::expected RimcWellPath_appendFishbones::execute() { auto wellPath = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h index b3c8375b99..18a508e29a 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h @@ -41,9 +41,9 @@ class RimcWellPath_addFracture : public caf::PdmObjectMethod public: RimcWellPath_addFracture( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_md; @@ -62,9 +62,9 @@ class RimcWellPath_addThermalFracture : public caf::PdmObjectMethod public: RimcWellPath_addThermalFracture( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmPtrField m_fractureTemplate; @@ -82,9 +82,9 @@ class RimcWellPath_appendPerforationInterval : public caf::PdmObjectMethod public: RimcWellPath_appendPerforationInterval( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_startMD; @@ -103,10 +103,10 @@ class RimcWellPath_multiSegmentWellSettings : public caf::PdmObjectMethod public: RimcWellPath_multiSegmentWellSettings( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - bool isNullptrValidResult() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + bool isNullptrValidResult() const override; + std::unique_ptr defaultResult() const override; }; //================================================================================================== @@ -119,10 +119,10 @@ class RimcWellPath_appendFishbones : public caf::PdmObjectMethod public: RimcWellPath_appendFishbones( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - bool isNullptrValidResult() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + bool isNullptrValidResult() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField> m_subLocations; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp index 5ae610f82d..bfde287e9d 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.cpp @@ -48,7 +48,7 @@ RimcRimWellPathGeometryDef_appendNewWellTarget::RimcRimWellPathGeometryDef_appen //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* RimcRimWellPathGeometryDef_appendNewWellTarget::execute() +std::expected RimcRimWellPathGeometryDef_appendNewWellTarget::execute() { auto geoDef = self(); diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h index 18b7058d64..281cb45f5b 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPathGeometryDef.h @@ -36,9 +36,9 @@ class RimcRimWellPathGeometryDef_appendNewWellTarget : public caf::PdmObjectMeth public: RimcRimWellPathGeometryDef_appendNewWellTarget( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField m_coordinate; diff --git a/Fwk/AppFwk/CMakeLists.txt b/Fwk/AppFwk/CMakeLists.txt index 1cedc7fb32..4126593c82 100644 --- a/Fwk/AppFwk/CMakeLists.txt +++ b/Fwk/AppFwk/CMakeLists.txt @@ -11,7 +11,7 @@ if(MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11)) ) endif() -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h b/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h index 46f079d785..a34a0e0fab 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmObjectMethod.h @@ -39,6 +39,8 @@ #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include + /// CAF_PDM_OBJECT_METHOD_SOURCE_INIT associates the self class keyword and the method keyword with the method factory /// Place this in the cpp file, preferably above the constructor #define CAF_PDM_OBJECT_METHOD_SOURCE_INIT( SelfClassName, MethodClassName, methodKeyword ) \ @@ -65,7 +67,7 @@ public: PdmObjectMethod( PdmObjectHandle* self ); // The returned object contains the results of the method and is the responsibility of the caller. - virtual PdmObjectHandle* execute() = 0; + virtual std::expected execute() = 0; // Some execute() methods can return a null pointer as a valid return value. // Return true here to allow this diff --git a/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmObjectMethodTest.cpp b/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmObjectMethodTest.cpp index d4a679cdd5..326631405b 100644 --- a/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmObjectMethodTest.cpp +++ b/Fwk/AppFwk/cafPdmScripting/cafPdmScripting_UnitTests/cafPdmObjectMethodTest.cpp @@ -16,10 +16,10 @@ class InheritedDemoObj_appendValves : public caf::PdmObjectMethod public: InheritedDemoObj_appendValves( caf::PdmObjectHandle* self ); - caf::PdmObjectHandle* execute() override; - bool resultIsPersistent() const override; - bool isNullptrValidResult() const override; - std::unique_ptr defaultResult() const override; + std::expected execute() override; + bool resultIsPersistent() const override; + bool isNullptrValidResult() const override; + std::unique_ptr defaultResult() const override; private: caf::PdmField> m_valveLocations; @@ -41,7 +41,7 @@ InheritedDemoObj_appendValves::InheritedDemoObj_appendValves( caf::PdmObjectHand //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObjectHandle* InheritedDemoObj_appendValves::execute() +std::expected InheritedDemoObj_appendValves::execute() { auto obj = self(); diff --git a/Fwk/CMakeLists.txt b/Fwk/CMakeLists.txt index e6ccecd21c..5a22abae64 100644 --- a/Fwk/CMakeLists.txt +++ b/Fwk/CMakeLists.txt @@ -8,7 +8,7 @@ else() message( STATUS "No buildcache found" ) endif() -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 23) project (TestCafAndVizFwk) diff --git a/GrpcInterface/CMakeLists.txt b/GrpcInterface/CMakeLists.txt index acb19392f9..678da4f99b 100644 --- a/GrpcInterface/CMakeLists.txt +++ b/GrpcInterface/CMakeLists.txt @@ -15,7 +15,7 @@ if(MSVC) add_definitions(-D_WIN32_WINNT=0x600) endif() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 23) add_definitions(-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) diff --git a/GrpcInterface/Python/rips/PythonExamples/error_handling.py b/GrpcInterface/Python/rips/PythonExamples/error_handling.py index 3e59a624f1..8b9ef0c4b9 100644 --- a/GrpcInterface/Python/rips/PythonExamples/error_handling.py +++ b/GrpcInterface/Python/rips/PythonExamples/error_handling.py @@ -7,6 +7,7 @@ import rips import grpc import tempfile + resinsight = rips.Instance.find() case = None @@ -14,22 +15,16 @@ case = None # Try loading a non-existing case. We should get a grpc.RpcError exception from the server try: case = resinsight.project.load_case("Nonsense") -except grpc.RpcError as e: - print( - "Expected Server Exception Received while loading case: ", e.code(), e.details() - ) +except rips.RipsError as e: + print("Expected Server Exception Received while loading case: ", e) # Try loading well paths from a non-existing folder. We should get a grpc.RpcError exception from the server try: well_path_files = resinsight.project.import_well_paths( well_path_folder="NONSENSE/NONSENSE" ) -except grpc.RpcError as e: - print( - "Expected Server Exception Received while loading wellpaths: ", - e.code(), - e.details(), - ) +except rips.RipsError as e: + print("Expected Server Exception Received while loading wellpaths: ", e) # Try loading well paths from an existing but empty folder. We should get a warning. try: @@ -42,7 +37,7 @@ try: print("Should get warnings below") for warning in resinsight.project.warnings(): print(warning) -except grpc.RpcError as e: +except rips.RipsError as e: print("Unexpected Server Exception caught!!!", e) case = resinsight.project.case(case_id=0) @@ -64,7 +59,7 @@ if case is not None: try: case.set_active_cell_property(results, "GENERATED", "POROAPPENDED", 0) print("Everything went well??") - except grpc.RpcError as e: + except RipsError as e: print("Expected Server Exception Received: ", e) except IndexError: print("Got index out of bounds error. This shouldn't happen here") diff --git a/GrpcInterface/Python/rips/__init__.py b/GrpcInterface/Python/rips/__init__.py index d2806e7f71..09e1218a2c 100644 --- a/GrpcInterface/Python/rips/__init__.py +++ b/GrpcInterface/Python/rips/__init__.py @@ -16,6 +16,7 @@ from .plot import Plot, PlotWindow from .contour_map import EclipseContourMap, GeoMechContourMap from .well_log_plot import WellLogPlot from .simulation_well import SimulationWell +from .exception import RipsError from typing import List diff --git a/GrpcInterface/Python/rips/exception.py b/GrpcInterface/Python/rips/exception.py new file mode 100644 index 0000000000..b1a78710dd --- /dev/null +++ b/GrpcInterface/Python/rips/exception.py @@ -0,0 +1,2 @@ +class RipsError(Exception): + pass diff --git a/GrpcInterface/Python/rips/pdmobject.py b/GrpcInterface/Python/rips/pdmobject.py index 336882948b..bf6021dbeb 100644 --- a/GrpcInterface/Python/rips/pdmobject.py +++ b/GrpcInterface/Python/rips/pdmobject.py @@ -16,6 +16,7 @@ import PdmObject_pb2_grpc import Commands_pb2 import Commands_pb2_grpc +from .exception import RipsError from typing import Any, Callable, TypeVar, Tuple, cast, Union, List, Optional, Type from typing_extensions import ParamSpec, Self @@ -36,7 +37,18 @@ C = TypeVar("C") def add_method(cls: C) -> Callable[[F], F]: def decorator(func: F) -> F: - setattr(cls, func.__name__, func) + def wrapper(*args, **kwargs): + try: + return func(*args, **kwargs) + except grpc.RpcError as e: + raise RipsError(e.details()) from None + + # Preserve the metadata of the original function + wrapper.__name__ = func.__name__ + wrapper.__doc__ = func.__doc__ + + # Add the wrapped function to the class + setattr(cls, func.__name__, wrapper) return func # returning func means func can still be used normally return decorator @@ -464,7 +476,10 @@ class PdmObjectBase: object=self._pb2_object, method=method_name, params=pb2_params ) - self._pdm_object_stub.CallPdmObjectMethod(request) + try: + self._pdm_object_stub.CallPdmObjectMethod(request) + except grpc.RpcError as exc: + raise RipsError("%s" % exc.details()) from None X = TypeVar("X") @@ -480,10 +495,12 @@ class PdmObjectBase: object=self._pb2_object, method=method_name, params=pb2_params ) - pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request) - - pdm_object = class_definition(pb2_object=pb2_object, channel=self.channel()) - return pdm_object + try: + pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request) + pdm_object = class_definition(pb2_object=pb2_object, channel=self.channel()) + return pdm_object + except grpc.RpcError as exc: + raise RipsError("%s" % exc.details()) from None O = TypeVar("O") @@ -499,17 +516,21 @@ class PdmObjectBase: object=self._pb2_object, method=method_name, params=pb2_params ) - pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request) + try: + pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request) - from .generated.generated_classes import class_from_keyword + from .generated.generated_classes import class_from_keyword - child_class_definition = class_from_keyword(pb2_object.class_keyword) - if child_class_definition is None: - return None + child_class_definition = class_from_keyword(pb2_object.class_keyword) + if child_class_definition is None: + return None - assert class_definition.__name__ == child_class_definition.__name__ - pdm_object = class_definition(pb2_object=pb2_object, channel=self.channel()) - return pdm_object + assert class_definition.__name__ == child_class_definition.__name__ + pdm_object = class_definition(pb2_object=pb2_object, channel=self.channel()) + return pdm_object + + except grpc.RpcError as exc: + raise RipsError("%s" % exc.details()) from None def update(self) -> None: """Sync all fields from the Python Object to ResInsight""" diff --git a/GrpcInterface/Python/rips/tests/test_cases.py b/GrpcInterface/Python/rips/tests/test_cases.py index 904f9401e6..a9a56e3559 100644 --- a/GrpcInterface/Python/rips/tests/test_cases.py +++ b/GrpcInterface/Python/rips/tests/test_cases.py @@ -180,7 +180,7 @@ def test_replaceCase(rips_instance, initialize_test): def test_loadNonExistingCase(rips_instance, initialize_test): case_path = "Nonsense/Nonsense/Nonsense" - with pytest.raises(grpc.RpcError): + with pytest.raises(rips.RipsError): assert rips_instance.project.load_case(case_path) diff --git a/GrpcInterface/Python/rips/tests/test_nnc_properties.py b/GrpcInterface/Python/rips/tests/test_nnc_properties.py index d9310ad4e4..7041301131 100644 --- a/GrpcInterface/Python/rips/tests/test_nnc_properties.py +++ b/GrpcInterface/Python/rips/tests/test_nnc_properties.py @@ -66,12 +66,12 @@ def test_non_existing_dynamic_values(rips_instance, initialize_test): casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID" case = rips_instance.project.load_case(path=casePath) - with pytest.raises(grpc.RpcError): + with pytest.raises(rips.RipsError): case.nnc_connections_dynamic_values("x", 0) def test_invalid_time_steps(rips_instance, initialize_test): casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID" case = rips_instance.project.load_case(path=casePath) - with pytest.raises(grpc.RpcError): + with pytest.raises(rips.RipsError): case.nnc_connections_generated_values("Formation Allan", 9999) diff --git a/GrpcInterface/Python/rips/tests/test_pdmobject.py b/GrpcInterface/Python/rips/tests/test_pdmobject.py new file mode 100644 index 0000000000..4ed49e8c7e --- /dev/null +++ b/GrpcInterface/Python/rips/tests/test_pdmobject.py @@ -0,0 +1,16 @@ +import sys +import os +import pytest + +sys.path.insert(1, os.path.join(sys.path[0], "../../")) +from rips import RipsError + + +def test_exception_on_object_method(rips_instance, initialize_test): + name = "the name" + nx = 12 + ny = 13 + nz = -1 + + with pytest.raises(RipsError, match=r"Invalid grid size"): + rips_instance.project.create_corner_point_grid(name, nx, ny, nz, [], [], []) diff --git a/GrpcInterface/Python/rips/tests/test_properties.py b/GrpcInterface/Python/rips/tests/test_properties.py index a6af199e91..e1fe983019 100644 --- a/GrpcInterface/Python/rips/tests/test_properties.py +++ b/GrpcInterface/Python/rips/tests/test_properties.py @@ -52,7 +52,7 @@ def test_10k_set_out_of_bounds(rips_instance, initialize_test): results = case.active_cell_property("DYNAMIC_NATIVE", "SOIL", 1) results.append(5.0) - with pytest.raises(grpc.RpcError): + with pytest.raises(rips.RipsError): assert case.set_active_cell_property(results, "GENERATED", "SOIL", 1) diff --git a/GrpcInterface/Python/rips/tests/test_wells_path_completions.py b/GrpcInterface/Python/rips/tests/test_wells_path_completions.py index 34bbeee1ea..ce78bc9700 100644 --- a/GrpcInterface/Python/rips/tests/test_wells_path_completions.py +++ b/GrpcInterface/Python/rips/tests/test_wells_path_completions.py @@ -87,7 +87,6 @@ def test_add_well_path_completions(rips_instance, initialize_test): def test_add_well_path_fracture_template(rips_instance, initialize_test): - # Add test for all properties # Some properties depend on availablility of other data and is not tested, these tests are commented out diff --git a/GrpcInterface/RiaGrpcPdmObjectService.cpp b/GrpcInterface/RiaGrpcPdmObjectService.cpp index f489b5dbd7..80a4c1214c 100644 --- a/GrpcInterface/RiaGrpcPdmObjectService.cpp +++ b/GrpcInterface/RiaGrpcPdmObjectService.cpp @@ -21,6 +21,7 @@ #include "RiaApplication.h" #include "RiaGrpcCallbacks.h" #include "RiaGrpcHelper.h" +#include "RiaLogging.h" #include "RimEclipseResultDefinition.h" #include "RimProject.h" @@ -552,23 +553,32 @@ grpc::Status RiaGrpcPdmObjectService::CallPdmObjectMethod( grpc::ServerContext* { copyPdmObjectFromRipsToCaf( &( request->params() ), method.get() ); - caf::PdmObjectHandle* result = method->execute(); - if ( result ) + std::expected result = method->execute(); + if ( !result.has_value() ) { - copyPdmObjectFromCafToRips( result, reply ); - if ( !method->resultIsPersistent() ) + RiaLogging::error( QString( "Method '%1' failed. Error: %2" ).arg( methodKeyword ).arg( result.error() ) ); + return grpc::Status( grpc::NOT_FOUND, result.error().toStdString() ); + } + else + { + caf::PdmObjectHandle* object = result.value(); + if ( object ) { - delete result; + copyPdmObjectFromCafToRips( object, reply ); + if ( !method->resultIsPersistent() ) + { + delete object; + } + return grpc::Status::OK; } - return grpc::Status::OK; - } - if ( method->isNullptrValidResult() ) - { - return grpc::Status::OK; - } + if ( method->isNullptrValidResult() ) + { + return grpc::Status::OK; + } - return grpc::Status( grpc::NOT_FOUND, "No result returned from Method" ); + return grpc::Status( grpc::NOT_FOUND, "No result returned from Method" ); + } } return grpc::Status( grpc::NOT_FOUND, "Could not find Method" ); }