Use a small lambda to avoid repeating code.

This commit is contained in:
Atgeirr Flø Rasmussen
2016-04-29 14:58:44 +02:00
parent 5fac939afb
commit 8ea71e2f15

View File

@@ -605,25 +605,24 @@ namespace Opm
void extractMessages()
{
// extract messages from deck.
auto extractMessage = [](const Message& msg) {
auto log_type = detail::convertMessageType(msg.mtype);
const auto& location = msg.location;
if (location) {
OpmLog::addMessage(log_type, Log::fileMessage(location.filename, location.lineno, msg.message));
} else {
OpmLog::addMessage(log_type, msg.message);
}
};
// Extract messages from Deck.
for(const auto& msg : deck_->getMessageContainer()) {
auto log_type = convertMessageType(msg.mtype);
const auto& location = msg.location;
if (location) {
OpmLog::addMessage(log_type, Log::fileMessage(location.filename, location.lineno, msg.message));
} else {
OpmLog::addMessage(log_type, msg.message);
}
extractMessage(msg);
}
// extract messages from EclipseState.
// Extract messages from EclipseState.
for (const auto& msg : eclipse_state_->getMessageContainer()) {
auto log_type = convertMessageType(msg.mtype);
const auto& location = msg.location;
if (location) {
OpmLog::addMessage(log_type, Log::fileMessage(location.filename, location.lineno, msg.message));
} else {
OpmLog::addMessage(log_type, msg.message);
}
extractMessage(msg);
}
}