ParseContext will throw OpmInputError
This commit is contained in:
parent
e01400fa18
commit
0512ab88b4
@ -19,6 +19,7 @@
|
||||
#ifndef OPM_ERROR_HPP
|
||||
#define OPM_ERROR_HPP
|
||||
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -94,6 +95,10 @@ public:
|
||||
location { loc }
|
||||
{}
|
||||
|
||||
OpmInputError(const std::string& msg) :
|
||||
m_what(msg)
|
||||
{}
|
||||
|
||||
const char * what() const throw()
|
||||
{
|
||||
return this->m_what.c_str();
|
||||
@ -124,7 +129,7 @@ private:
|
||||
// The location member is here for debugging; depending on the msg_fmt
|
||||
// passed in the constructor we might not have captured all the information
|
||||
// in the location argument passed to the constructor.
|
||||
KeywordLocation location;
|
||||
std::optional<KeywordLocation> location;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -2204,7 +2204,8 @@ void reportUnsupportedKeywords(std::vector<Opm::SummaryConfigNode> keywords)
|
||||
|
||||
for (auto node = keywords.begin(); node != uend; ++node) {
|
||||
const auto& location = node->location();
|
||||
::Opm::OpmLog::warning("Unhandled summary keyword '" + node->keyword() + "' at " + location.filename + ", line " + std::to_string(location.lineno));
|
||||
Opm::OpmLog::warning(Opm::OpmInputError::format("Unhandled summary keyword {keyword}\n"
|
||||
"In {file} line {line}", location));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -411,14 +411,12 @@ void VFPProdTable::check(const DeckKeyword& keyword, const double table_scaling_
|
||||
|
||||
if (!points.empty()) {
|
||||
const auto& location = keyword.location();
|
||||
OpmLog::warning("VFP table for production wells has BHP versus THP not "
|
||||
+ std::string("monotonically increasing.\nThis may cause convergence ")
|
||||
+ "issues due to switching between BHP and THP control mode."
|
||||
+ std::string("\nIn keyword VFPPROD table number ")
|
||||
+ std::to_string(m_table_num)
|
||||
+ ", file " + location.filename
|
||||
+ ", line " + std::to_string(location.lineno)
|
||||
+ "\n");
|
||||
OpmLog::warning(fmt::format("VFP table {0} has BHP versus THP not increasing in keyword VFPPROD.\n"
|
||||
"In {1} line {2}\n"
|
||||
"This may cause convergence issues due to switching between BHP and THP control.",
|
||||
m_table_num,
|
||||
location.filename,
|
||||
location.lineno));
|
||||
OpmLog::note(points);
|
||||
}
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ inline void keywordR2R( SummaryConfig::keyword_list& /* list */,
|
||||
const DeckKeyword& keyword)
|
||||
{
|
||||
const auto& location = keyword.location();
|
||||
std::string msg_fmt = "Region to region summary keyword {keyword} is ignored\n";
|
||||
std::string msg_fmt = "Region to region summary keyword {keyword} is ignored\n"
|
||||
"In {file} line {line}";
|
||||
parseContext.handleError(ParseContext::SUMMARY_UNHANDLED_KEYWORD, msg_fmt, location, errors);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||
#include <opm/common/utility/String.hpp>
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -137,11 +138,12 @@ namespace Opm {
|
||||
|
||||
void ParseContext::handleError(
|
||||
const std::string& errorKey,
|
||||
const std::string& msg,
|
||||
const std::string& msg_fmt,
|
||||
const std::optional<KeywordLocation>& location,
|
||||
ErrorGuard& errors) const {
|
||||
|
||||
InputError::Action action = get( errorKey );
|
||||
std::string msg = location ? OpmInputError::format(msg_fmt, *location) : msg_fmt;
|
||||
|
||||
if (action == InputError::IGNORE) {
|
||||
errors.addWarning(errorKey, msg);
|
||||
@ -160,7 +162,10 @@ namespace Opm {
|
||||
// make sure the error object does not terminate the application
|
||||
// when it goes out of scope.
|
||||
errors.clear();
|
||||
throw std::invalid_argument(errorKey + ": " + msg);
|
||||
if (location)
|
||||
throw OpmInputError(msg_fmt, *location);
|
||||
else
|
||||
throw OpmInputError(msg_fmt, {});
|
||||
}
|
||||
|
||||
if (action == InputError::EXIT1) {
|
||||
@ -177,7 +182,7 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
void ParseContext::handleUnknownKeyword(const std::string& keyword, const std::optional<KeywordLocation>& location, ErrorGuard& errors) const {
|
||||
void ParseContext::handleUnknownKeyword(const std::string& keyword, const std::optional<KeywordLocation>& location, ErrorGuard& errors) const {
|
||||
if (this->ignore_keywords.find(keyword) == this->ignore_keywords.end()) {
|
||||
std::string msg = "Unknown keyword: " + keyword;
|
||||
this->handleError(ParseContext::PARSE_UNKNOWN_KEYWORD, msg, location, errors);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
|
||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
||||
@ -137,7 +138,7 @@ TSTEP
|
||||
Runspec runspec (deck1);
|
||||
|
||||
// The ACTIONX keyword has no matching 'ENDACTIO' -> exception
|
||||
BOOST_CHECK_THROW(Schedule(deck1, grid1, fp, runspec, python), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Schedule(deck1, grid1, fp, runspec, python), OpmInputError);
|
||||
|
||||
Schedule sched(deck2, grid1, fp, runspec, python);
|
||||
BOOST_CHECK( !sched.hasWell("W1") );
|
||||
@ -146,7 +147,7 @@ TSTEP
|
||||
// The deck3 contains the 'GRID' keyword in the ACTIONX block - that is not a whitelisted keyword.
|
||||
ParseContext parseContext( {{ParseContext::ACTIONX_ILLEGAL_KEYWORD, InputError::THROW_EXCEPTION}} );
|
||||
ErrorGuard errors;
|
||||
BOOST_CHECK_THROW(Schedule(deck3, grid1, fp, runspec, parseContext, errors, python), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Schedule(deck3, grid1, fp, runspec, parseContext, errors, python), OpmInputError);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
@ -395,7 +396,7 @@ BOOST_AUTO_TEST_CASE(WrongDistanceCOMPSEGS) {
|
||||
Opm::ErrorGuard errorGuard;
|
||||
Opm::ParseContext parseContext;
|
||||
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard), Opm::OpmInputError);
|
||||
|
||||
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::IGNORE);
|
||||
BOOST_CHECK_NO_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard));
|
||||
@ -452,7 +453,7 @@ BOOST_AUTO_TEST_CASE(NegativeDepthCOMPSEGS) {
|
||||
Opm::ErrorGuard errorGuard;
|
||||
Opm::ParseContext parseContext;
|
||||
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard), Opm::OpmInputError);
|
||||
|
||||
parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::IGNORE);
|
||||
BOOST_CHECK_NO_THROW( Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard) );
|
||||
|
@ -73,14 +73,14 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeyword) {
|
||||
|
||||
parser.addKeyword<ParserKeywords::DIMENS>();
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext , errors) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext , errors) , OpmInputError);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW( parser.parseString( deck1 , parseContext , errors) );
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext , errors) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext , errors) , OpmInputError);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
|
||||
@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeyword) {
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext , errors) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext , errors) , OpmInputError);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
|
||||
@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeywordII) {
|
||||
|
||||
parser.addKeyword<ParserKeywords::DIMENS>();
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext, errors ) , OpmInputError);
|
||||
parseContext.ignoreKeyword("RUNSPEC");
|
||||
BOOST_CHECK_NO_THROW( parser.parseString( deck1 , parseContext, errors ) );
|
||||
}
|
||||
@ -135,14 +135,14 @@ BOOST_AUTO_TEST_CASE(Handle_extra_records) {
|
||||
parser.addKeyword<ParserKeywords::EQLDIMS>();
|
||||
parser.addKeyword<ParserKeywords::EQUIL>();
|
||||
parser.addKeyword<ParserKeywords::GRID>();
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ) , OpmInputError );
|
||||
|
||||
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::IGNORE );
|
||||
parser.parseString( deck_string , parseContext, errors );
|
||||
BOOST_CHECK( parser.hasKeyword( "GRID" ) );
|
||||
|
||||
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ) , OpmInputError);
|
||||
}
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE(Handle_extra_records_2) {
|
||||
parser.addKeyword<ParserKeywords::DIMENS>();
|
||||
|
||||
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::IGNORE );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ), std::invalid_argument );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext, errors ), OpmInputError );
|
||||
}
|
||||
|
||||
|
||||
@ -225,7 +225,7 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeyword_DATA) {
|
||||
BOOST_CHECK( deck.hasKeyword( "RUNSPEC") );
|
||||
BOOST_CHECK( deck.hasKeyword( "DIMENS") );
|
||||
}
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string2 , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck_string2 , parseContext, errors ) , OpmInputError);
|
||||
}
|
||||
|
||||
|
||||
@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE(TEST_UNKNOWN_OPERATE) {
|
||||
Parser parser(false);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck , parseContext, errors ) , OpmInputError);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE );
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
||||
@ -280,7 +280,7 @@ BOOST_AUTO_TEST_CASE( CheckMissingSizeKeyword) {
|
||||
parser.addKeyword<ParserKeywords::SOLUTION>();
|
||||
|
||||
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck , parseContext, errors ) , OpmInputError);
|
||||
|
||||
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseContext, errors ) );
|
||||
@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE( CheckUnsupportedInSCHEDULE ) {
|
||||
BOOST_CHECK_NO_THROW( Schedule( deckUnSupported, grid , fp, runspec, parseContext, errors, python ));
|
||||
|
||||
parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( Schedule( deckUnSupported , grid , fp, runspec , parseContext , errors, python), std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Schedule( deckUnSupported , grid , fp, runspec , parseContext , errors, python), OpmInputError );
|
||||
BOOST_CHECK_NO_THROW( Schedule( deckSupported , grid , fp, runspec , parseContext, errors, python));
|
||||
}
|
||||
|
||||
@ -376,8 +376,8 @@ BOOST_AUTO_TEST_CASE(TestRandomSlash) {
|
||||
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::THROW_EXCEPTION);
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext, errors ) , OpmInputError);
|
||||
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext, errors ) , OpmInputError);
|
||||
|
||||
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE);
|
||||
@ -424,7 +424,7 @@ BOOST_AUTO_TEST_CASE(TestCOMPORD) {
|
||||
BOOST_CHECK_NO_THROW( Schedule( deck , grid , fp, runspec, parseContext, errors, python ));
|
||||
|
||||
parseContext.update( ParseContext::UNSUPPORTED_COMPORD_TYPE , InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW( Schedule( deck, grid , fp, runspec , parseContext, errors, python), std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Schedule( deck, grid , fp, runspec , parseContext, errors, python), OpmInputError );
|
||||
}
|
||||
|
||||
|
||||
@ -441,7 +441,7 @@ BOOST_AUTO_TEST_CASE(TestNew) {
|
||||
BOOST_CHECK_EQUAL( false , parseContext.hasKey("NO"));
|
||||
parseContext.addKey("NEW_KEY", InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_EQUAL( true , parseContext.hasKey("NEW_KEY"));
|
||||
BOOST_CHECK_THROW( parseContext.get("NO") , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( parseContext.get("NO") , std::invalid_argument);
|
||||
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::THROW_EXCEPTION );
|
||||
parseContext.addKey("KEY2", InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::THROW_EXCEPTION );
|
||||
@ -498,7 +498,7 @@ BOOST_AUTO_TEST_CASE( test_too_much_data ) {
|
||||
|
||||
|
||||
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deckString , parseContext, errors ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString( deckString , parseContext, errors ) , OpmInputError);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputError::IGNORE );
|
||||
auto deck = parser.parseString( deckString , parseContext, errors );
|
||||
@ -530,6 +530,12 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) {
|
||||
1000*0.25 /
|
||||
TOPS
|
||||
100*0.25 /
|
||||
PERMX
|
||||
1000*1 /
|
||||
PERMY
|
||||
1000*1 /
|
||||
PERMZ
|
||||
1000*1 /
|
||||
SCHEDULE
|
||||
DATES -- 1
|
||||
10 OKT 2008 /
|
||||
@ -770,7 +776,7 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) {
|
||||
FieldPropsManager fp( deckUnSupported, Phases{true, true, true}, grid, table);
|
||||
Runspec runspec( deckUnSupported);
|
||||
|
||||
BOOST_CHECK_THROW( Schedule( deckUnSupported , grid , fp, runspec , parseContext, errors, python), std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Schedule( deckUnSupported , grid , fp, runspec , parseContext, errors, python), OpmInputError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -813,7 +819,7 @@ RPTRUNSPEC
|
||||
BOOST_CHECK( deck.hasKeyword("RPTRUNSP") );
|
||||
|
||||
context.update(ParseContext::PARSE_LONG_KEYWORD, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW( parser.parseString(deck_string, context, error), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString(deck_string, context, error), OpmInputError);
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
@ -44,7 +45,7 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
|
||||
Opm::ErrorGuard errors;
|
||||
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFilePath.string() , parseContext, errors) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFilePath.string() , parseContext, errors) , Opm::OpmInputError);
|
||||
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW(parser.parseFile(inputFilePath.string() , parseContext, errors));
|
||||
@ -123,9 +124,9 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) {
|
||||
Opm::ErrorGuard errors;
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
|
||||
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFile1Path.string(), parseContext, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFile2Path.string(), parseContext, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFile3Path.string(), parseContext, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFile1Path.string(), parseContext, errors), Opm::OpmInputError);
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFile2Path.string(), parseContext, errors), Opm::OpmInputError);
|
||||
BOOST_CHECK_THROW(parser.parseFile(inputFile3Path.string(), parseContext, errors), Opm::OpmInputError);
|
||||
#else
|
||||
// for case-insensitive filesystems, the include statement will
|
||||
// always work regardless of how the capitalization of the
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <opm/parser/eclipse/Utility/Typetools.hpp>
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
@ -323,7 +324,7 @@ BOOST_AUTO_TEST_CASE( PATHS_has_global_scope ) {
|
||||
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION);
|
||||
const auto deck = parser.parseFile( prefix() + "parser/PATHSInInclude.data", parseContext, errors );
|
||||
BOOST_CHECK(deck.hasKeyword("OIL"));
|
||||
BOOST_CHECK_THROW( parser.parseFile( prefix() + "parser/PATHSInIncludeInvalid.data", parseContext, errors ), std::invalid_argument );
|
||||
BOOST_CHECK_THROW( parser.parseFile( prefix() + "parser/PATHSInIncludeInvalid.data", parseContext, errors ), OpmInputError );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PATHS_with_backslashes ) {
|
||||
@ -1226,10 +1227,10 @@ BOOST_AUTO_TEST_CASE(Parse_RawRecordTooManyItems_Throws) {
|
||||
BOOST_CHECK_NO_THROW(parserRecord.parse(parseContext, errors, rawRecord, unit_system, unit_system, KeywordLocation()));
|
||||
|
||||
RawRecord rawRecordOneExtra( "3 3 3 4 " );
|
||||
BOOST_CHECK_THROW(parserRecord.parse(parseContext, errors, rawRecordOneExtra, unit_system, unit_system, KeywordLocation()), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parserRecord.parse(parseContext, errors, rawRecordOneExtra, unit_system, unit_system, KeywordLocation()), OpmInputError);
|
||||
|
||||
RawRecord rawRecordForgotRecordTerminator( "3 3 3 \n 4 4 4 " );
|
||||
BOOST_CHECK_THROW(parserRecord.parse(parseContext, errors, rawRecordForgotRecordTerminator, unit_system, unit_system, KeywordLocation()), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parserRecord.parse(parseContext, errors, rawRecordForgotRecordTerminator, unit_system, unit_system, KeywordLocation()), OpmInputError);
|
||||
|
||||
}
|
||||
|
||||
@ -2333,7 +2334,7 @@ GUIDERATE
|
||||
)";
|
||||
|
||||
parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW(parser.parseString(deck_string, parseContext, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser.parseString(deck_string, parseContext, errors), OpmInputError);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputError::IGNORE);
|
||||
auto deck = parser.parseString(deck_string, parseContext, errors);
|
||||
|
@ -405,7 +405,7 @@ BOOST_AUTO_TEST_CASE(RPTRST_mixed_mnemonics_int_list) {
|
||||
ErrorGuard errors;
|
||||
auto deck = Parser().parseString( data, parseContext, errors );
|
||||
parseContext.update(ParseContext::RPT_MIXED_STYLE, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW( RestartConfig( TimeMap(deck), deck, parseContext, errors ), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( RestartConfig( TimeMap(deck), deck, parseContext, errors ), OpmInputError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RPTRST) {
|
||||
@ -613,7 +613,7 @@ BOOST_AUTO_TEST_CASE(RPTRST_FORMAT_ERROR) {
|
||||
auto deck1 = parser.parseString( deckData1, ctx, errors );
|
||||
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputError::IGNORE);
|
||||
ctx.update(ParseContext::RPT_MIXED_STYLE, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW(RestartConfig(TimeMap(deck1), deck1, ctx, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(RestartConfig(TimeMap(deck1), deck1, ctx, errors), OpmInputError);
|
||||
|
||||
ctx.update(ParseContext::RPT_MIXED_STYLE, InputError::IGNORE);
|
||||
RestartConfig rstConfig1( TimeMap(deck1), deck1, ctx, errors );
|
||||
@ -644,7 +644,7 @@ BOOST_AUTO_TEST_CASE(RPTRST_FORMAT_ERROR) {
|
||||
auto deck2 = parser.parseString( deckData2, ctx, errors );
|
||||
|
||||
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW(RestartConfig(TimeMap(deck2), deck2, ctx, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(RestartConfig(TimeMap(deck2), deck2, ctx, errors), OpmInputError);
|
||||
ctx.update(ParseContext::RPT_UNKNOWN_MNEMONIC, InputError::IGNORE);
|
||||
|
||||
RestartConfig rstConfig2( TimeMap(deck2), deck2, ctx, errors );
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
|
||||
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
@ -1058,7 +1059,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException) {
|
||||
"/\n";
|
||||
|
||||
|
||||
BOOST_CHECK_THROW(make_schedule(input), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(make_schedule(input), Opm::OpmInputError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException2) {
|
||||
@ -1068,7 +1069,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException2) {
|
||||
" OP_1 LRAT /\n"
|
||||
" OP_1 RESV 1801.05 /\n"
|
||||
"/\n";
|
||||
BOOST_CHECK_THROW(make_schedule(input), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(make_schedule(input), Opm::OpmInputError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(createDeckWithWPIMULT) {
|
||||
@ -1181,7 +1182,7 @@ BOOST_AUTO_TEST_CASE(WELSPECS_WGNAME_SPACE) {
|
||||
ErrorGuard errors;
|
||||
|
||||
parseContext.update(ParseContext::PARSE_WGNAME_SPACE, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW( Opm::Schedule(deck, grid, fp, runspec, parseContext, errors, python), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( Opm::Schedule(deck, grid, fp, runspec, parseContext, errors, python), Opm::OpmInputError);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_WGNAME_SPACE, InputError::IGNORE);
|
||||
BOOST_CHECK_NO_THROW( Opm::Schedule(deck, grid, fp, runspec, parseContext, errors, python));
|
||||
@ -1804,7 +1805,7 @@ BOOST_AUTO_TEST_CASE(unsupportedOptionWHISTCTL) {
|
||||
TableManager table ( deck );
|
||||
FieldPropsManager fp( deck, Phases{true, true, true}, grid, table);
|
||||
Runspec runspec (deck);
|
||||
BOOST_CHECK_THROW(Schedule(deck, grid, fp, runspec, python), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Schedule(deck, grid, fp, runspec, python), Opm::OpmInputError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(move_HEAD_I_location) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
#include <opm/io/eclipse/SummaryNode.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
@ -300,7 +301,7 @@ BOOST_AUTO_TEST_CASE(region2region) {
|
||||
names.begin(), names.end() );
|
||||
|
||||
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW( createSummary(input, parseContext), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( createSummary(input, parseContext), OpmInputError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(completions) {
|
||||
@ -449,7 +450,7 @@ BOOST_AUTO_TEST_CASE(INVALID_WELL1) {
|
||||
"NEW-WELL /\n"
|
||||
"/\n";
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
|
||||
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
|
||||
@ -461,7 +462,7 @@ BOOST_AUTO_TEST_CASE(INVALID_WELL2) {
|
||||
const auto input = "WWCT\n"
|
||||
" NEW-WELL /\n";
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
|
||||
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
|
||||
@ -472,7 +473,7 @@ BOOST_AUTO_TEST_CASE(UNDEFINED_UDQ_WELL) {
|
||||
const auto input = "WUWCT\n"
|
||||
"/\n";
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
|
||||
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNDEFINED_UDQ, InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
|
||||
@ -486,7 +487,7 @@ BOOST_AUTO_TEST_CASE(INVALID_GROUP) {
|
||||
const auto input = "GWCT\n"
|
||||
" NEW-GR /\n";
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( createSummary( input , parseContext ) , OpmInputError);
|
||||
|
||||
parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW( createSummary( input , parseContext ));
|
||||
@ -619,7 +620,7 @@ WOPRL
|
||||
|
||||
ParseContext parseContext;
|
||||
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW(createSummary( input, parseContext ), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(createSummary( input, parseContext ), OpmInputError);
|
||||
parseContext.update(ParseContext::SUMMARY_UNHANDLED_KEYWORD, InputError::IGNORE);
|
||||
BOOST_CHECK_NO_THROW( createSummary(input, parseContext ));
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ Copyright 2018 Statoil ASA.
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <limits>
|
||||
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
#include <opm/parser/eclipse/Utility/Typetools.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
@ -155,12 +156,12 @@ BOOST_AUTO_TEST_CASE(TEST)
|
||||
This expression has a well set as target type, and involves group with
|
||||
wildcard that is not supported by flow.
|
||||
*/
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "WUWI2", location, {"GOPR", "G*", "*", "2.0"}), std::logic_error);
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "WUWI2", location, {"GOPR", "G*", "*", "2.0"}), OpmInputError);
|
||||
|
||||
/*
|
||||
UDQVarType == BLOCK is not yet supported.
|
||||
*/
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "WUWI2", location, {"BPR", "1","1", "1", "*", "2.0"}), std::logic_error);
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "WUWI2", location, {"BPR", "1","1", "1", "*", "2.0"}), OpmInputError);
|
||||
}
|
||||
|
||||
|
||||
@ -1284,7 +1285,7 @@ BOOST_AUTO_TEST_CASE(UDQ_PARSE_ERROR) {
|
||||
}
|
||||
|
||||
parseContext.update(ParseContext::UDQ_PARSE_ERROR, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "WUBHP", location, tokens, parseContext, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "WUBHP", location, tokens, parseContext, errors), OpmInputError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDQ_TYPE_ERROR) {
|
||||
@ -1318,7 +1319,7 @@ BOOST_AUTO_TEST_CASE(UDQ_TYPE_ERROR) {
|
||||
parseContext.update(ParseContext::UDQ_TYPE_ERROR, InputError::THROW_EXCEPTION);
|
||||
|
||||
// This fails because the well expression (WBHP + 1) is assigned to the field variable FUBHP
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "FUBHP", location, tokens1, parseContext, errors), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( UDQDefine(udqp, "FUBHP", location, tokens1, parseContext, errors), OpmInputError);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
-- Comment
|
||||
OIL
|
||||
|
||||
GRIDUNIT
|
||||
METRES /
|
||||
|
||||
GRUDINT -- A wrong, or unknown keyword
|
||||
"text" 3 5 /
|
||||
3 3 3 3 3 3 /
|
||||
/
|
||||
|
||||
|
||||
|
||||
RADFIN4
|
||||
'NAME' 213 123 123 123 7 7 18 18 18 18 /
|
@ -21,6 +21,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
@ -198,7 +199,24 @@ BOOST_AUTO_TEST_CASE(parse_fileWithBPRKeyword_dataiscorrect) {
|
||||
/***************** Testing non-recognized keywords ********************/
|
||||
BOOST_AUTO_TEST_CASE(parse_unknownkeyword_exceptionthrown) {
|
||||
Parser parser;
|
||||
BOOST_CHECK_THROW( parser.parseFile(pathprefix() + "someobscureelements.data"), std::invalid_argument);
|
||||
std::string deck = R"(
|
||||
-- Comment
|
||||
OIL
|
||||
|
||||
GRIDUNIT
|
||||
METRES /
|
||||
|
||||
GRUDINT -- A wrong, or unknown keyword
|
||||
"text" 3 5 /
|
||||
3 3 3 3 3 3 /
|
||||
/
|
||||
|
||||
|
||||
|
||||
RADFIN4
|
||||
'NAME' 213 123 123 123 7 7 18 18 18 18 /
|
||||
)";
|
||||
BOOST_CHECK_THROW( parser.parseString(deck), OpmInputError);
|
||||
}
|
||||
|
||||
/*********************Testing truncated (default) records ***************************/
|
||||
@ -207,7 +225,18 @@ BOOST_AUTO_TEST_CASE(parse_unknownkeyword_exceptionthrown) {
|
||||
// Datafile contains 3 RADFIN4 keywords. One fully specified, one with 2 out of 11 items, and one with no items.
|
||||
BOOST_AUTO_TEST_CASE(parse_truncatedrecords_deckFilledWithDefaults) {
|
||||
Parser parser;
|
||||
auto deck = parser.parseFile(pathprefix() + "truncated_records.data");
|
||||
std::string deck_string = R"(
|
||||
-- Comment
|
||||
OIL
|
||||
|
||||
RADFIN4
|
||||
'NAME' 213 123 123 123 7 7 18 18 18 18 /
|
||||
|
||||
RADFIN4
|
||||
'NAME' 213 123 123 123 7 7 18 18 18 /
|
||||
)";
|
||||
|
||||
auto deck = parser.parseString(deck_string);
|
||||
BOOST_CHECK_EQUAL(3U, deck.size());
|
||||
const auto& radfin4_0_full= deck.getKeyword("RADFIN4", 0);
|
||||
const auto& radfin4_1_partial= deck.getKeyword("RADFIN4", 1);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define BOOST_TEST_MODULE ParserKeywordsIntegrationTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
||||
@ -216,10 +217,10 @@ BOOST_AUTO_TEST_CASE( SORWMIS ) {
|
||||
|
||||
Parser parser;
|
||||
// missing miscible keyword
|
||||
BOOST_CHECK_THROW (parser.parseString(sorwmisData), std::invalid_argument );
|
||||
BOOST_CHECK_THROW (parser.parseString(sorwmisData), OpmInputError );
|
||||
|
||||
//too many tables
|
||||
BOOST_CHECK_THROW( parser.parseString(miscibleTightData + sorwmisData), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( parser.parseString(miscibleTightData + sorwmisData), OpmInputError);
|
||||
|
||||
auto deck1 = parser.parseString(miscibleData + sorwmisData);
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <boost/version.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp>
|
||||
|
||||
#include <opm/common/utility/OpmInputError.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
@ -430,7 +431,7 @@ BOOST_AUTO_TEST_CASE(WellDims)
|
||||
|
||||
BOOST_CHECK_THROW( Opm::checkConsistentArrayDimensions(cse.es , cse.sched,
|
||||
parseContext, cse.guard),
|
||||
std::invalid_argument);
|
||||
Opm::OpmInputError);
|
||||
|
||||
setWellDimsContext(Opm::InputError::DELAYED_EXIT1, parseContext);
|
||||
Opm::checkConsistentArrayDimensions(cse.es , cse.sched,
|
||||
@ -467,7 +468,7 @@ BOOST_AUTO_TEST_CASE(WellDims_ManyChildGroups)
|
||||
// There *should* be errors from dimension checking
|
||||
BOOST_CHECK_THROW( Opm::checkConsistentArrayDimensions(cse.es , cse.sched,
|
||||
parseContext, cse.guard),
|
||||
std::invalid_argument);
|
||||
Opm::OpmInputError);
|
||||
|
||||
setWellDimsContext(Opm::InputError::DELAYED_EXIT1, parseContext);
|
||||
Opm::checkConsistentArrayDimensions(cse.es , cse.sched,
|
||||
|
Loading…
Reference in New Issue
Block a user