From c1ea9665487cd05ece6ea77d72606163425bc50d Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Sun, 27 Sep 2020 22:11:37 +0200 Subject: [PATCH] Add static function OpmInputError::format() --- opm/common/utility/OpmInputError.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/opm/common/utility/OpmInputError.hpp b/opm/common/utility/OpmInputError.hpp index e29c595c6..bbd138aef 100644 --- a/opm/common/utility/OpmInputError.hpp +++ b/opm/common/utility/OpmInputError.hpp @@ -16,14 +16,15 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ +#ifndef OPM_ERROR_HPP +#define OPM_ERROR_HPP #include #include #include -#ifndef OPM_ERROR_HPP -#define OPM_ERROR_HPP +#include 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;