Guard nullpointer access and catch exceptions

This commit is contained in:
Magne Sjaastad 2021-06-14 08:01:28 +02:00
parent 60dbb8a715
commit 1350c56eaf
2 changed files with 2885 additions and 2890 deletions

View File

@ -1,93 +1,88 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2020- Equinor ASA // Copyright (C) 2020- Equinor ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RimVfpTableExtractor.h" #include "RimVfpTableExtractor.h"
// #include "RiaApplication.h" #include "cafPdmUiItem.h"
#include "cafUtils.h"
// #include "RimCase.h"
// #include "RimEclipseCase.h" #include "opm/parser/eclipse/Parser/Parser.hpp"
// #include "RimGeoMechCase.h"
// #include "RimOilField.h" //--------------------------------------------------------------------------------------------------
// #include "RimProject.h" ///
// #include "RimWellLogFile.h" //--------------------------------------------------------------------------------------------------
// #include "RimWellPath.h" std::vector<Opm::VFPInjTable> RimVfpTableExtractor::extractVfpInjectionTables( const std::string& filename )
// #include "RimWellPathCollection.h" {
std::vector<Opm::VFPInjTable> tables;
#include "cafPdmUiItem.h"
#include "cafUtils.h" try
{
// #include <QDateTime> Opm::Parser parser;
// #include <QDir> auto deck = parser.parseFile( filename );
// #include <QFileInfo>
std::string myKeyword = "VFPINJ";
// #include "opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp" auto keywordList = deck.getKeywordList( myKeyword );
// #include "opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp"
#include "opm/parser/eclipse/Parser/Parser.hpp" Opm::UnitSystem unitSystem;
//-------------------------------------------------------------------------------------------------- for ( auto kw : keywordList )
/// {
//-------------------------------------------------------------------------------------------------- auto name = kw->name();
std::vector<Opm::VFPInjTable> RimVfpTableExtractor::extractVfpInjectionTables( const std::string& filename )
{ Opm::VFPInjTable table( *kw, unitSystem );
std::vector<Opm::VFPInjTable> tables; tables.push_back( table );
}
Opm::Parser parser; }
auto deck = parser.parseFile( filename ); catch ( ... )
{
std::string myKeyword = "VFPINJ"; }
auto keywordList = deck.getKeywordList( myKeyword );
return tables;
Opm::UnitSystem unitSystem; }
for ( auto kw : keywordList ) //--------------------------------------------------------------------------------------------------
{ ///
auto name = kw->name(); //--------------------------------------------------------------------------------------------------
std::vector<Opm::VFPProdTable> RimVfpTableExtractor::extractVfpProductionTables( const std::string& filename )
Opm::VFPInjTable table( *kw, unitSystem ); {
tables.push_back( table ); std::vector<Opm::VFPProdTable> tables;
}
try
return tables; {
} Opm::Parser parser;
auto deck = parser.parseFile( filename );
//--------------------------------------------------------------------------------------------------
/// std::string myKeyword = "VFPPROD";
//-------------------------------------------------------------------------------------------------- auto keywordList = deck.getKeywordList( myKeyword );
std::vector<Opm::VFPProdTable> RimVfpTableExtractor::extractVfpProductionTables( const std::string& filename )
{ Opm::UnitSystem unitSystem;
std::vector<Opm::VFPProdTable> tables;
for ( auto kw : keywordList )
Opm::Parser parser; {
auto deck = parser.parseFile( filename ); auto name = kw->name();
std::string myKeyword = "VFPPROD"; Opm::VFPProdTable table( *kw, unitSystem );
auto keywordList = deck.getKeywordList( myKeyword ); tables.push_back( table );
}
Opm::UnitSystem unitSystem; }
catch ( ... )
for ( auto kw : keywordList ) {
{ }
auto name = kw->name();
return tables;
Opm::VFPProdTable table( *kw, unitSystem ); }
tables.push_back( table );
}
return tables;
}