log messages to message container.

This commit is contained in:
Liu Ming
2016-05-09 17:01:25 +08:00
committed by Joakim Hove
parent e538ed43dc
commit c8625b2fc0
2 changed files with 8 additions and 3 deletions

View File

@@ -77,15 +77,20 @@ namespace Opm {
Message::type ParseContext::handleError(
const std::string& errorKey,
MessageContainer& msgContainer,
const std::string& msg ) const {
InputError::Action action = get( errorKey );
if (action == InputError::WARN)
if (action == InputError::WARN) {
msgContainer.warning(msg);
return Message::Warning;
}
else if (action == InputError::THROW_EXCEPTION)
else if (action == InputError::THROW_EXCEPTION) {
msgContainer.error(msg);
throw std::invalid_argument(errorKey + ": " + msg);
}
return Message::Debug;

View File

@@ -80,7 +80,7 @@ namespace Opm {
public:
ParseContext();
ParseContext(const std::vector<std::pair<std::string , InputError::Action>> initial);
Message::type handleError( const std::string& errorKey, const std::string& msg ) const;
Message::type handleError( const std::string& errorKey, MessageContainer& msgContainer, const std::string& msg ) const;
bool hasKey(const std::string& key) const;
ParseContext withKey(const std::string& key, InputError::Action action = InputError::WARN) const;
ParseContext& withKey(const std::string& key, InputError::Action action = InputError::WARN);