Add static function OpmInputError::format()

This commit is contained in:
Joakim Hove
2020-09-27 22:11:37 +02:00
parent 8c2ed38cf4
commit c1ea966548

View File

@@ -16,14 +16,15 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_ERROR_HPP
#define OPM_ERROR_HPP
#include <stdexcept>
#include <string>
#include <fmt/format.h>
#ifndef OPM_ERROR_HPP
#define OPM_ERROR_HPP
#include <opm/common/OpmLog/KeywordLocation.hpp>
namespace Opm {
@@ -73,10 +74,7 @@ public:
OpmInputError(const std::string& msg_fmt, const KeywordLocation& loc) :
m_what(fmt::format(msg_fmt,
fmt::arg("keyword", loc.keyword),
fmt::arg("file", loc.filename),
fmt::arg("line", loc.lineno))),
m_what(OpmInputError::format(msg_fmt, loc)),
location(loc)
{}
@@ -86,6 +84,14 @@ public:
}
static std::string format(const std::string& msg_fmt, const KeywordLocation& loc) {
return fmt::format(msg_fmt,
fmt::arg("keyword", loc.keyword),
fmt::arg("file", loc.filename),
fmt::arg("line", loc.lineno));
}
private:
std::string m_what;