summaryrefslogtreecommitdiff
path: root/src/lib/exceptions.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-23 21:53:32 +0100
committerCarl Hetherington <cth@carlh.net>2024-12-26 00:27:08 +0100
commit8caf013a9b8d709ed7c3d5e9febee0067e6fcf1f (patch)
tree40da87cb357e8b1c54a1464bdbac2d014640e30c /src/lib/exceptions.h
parentcec6ff92aef45c687085ecfc1059004407c18c57 (diff)
Replace String::compose with fmt::format().
Diffstat (limited to 'src/lib/exceptions.h')
-rw-r--r--src/lib/exceptions.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h
index f7e9c9dc5..406ef8443 100644
--- a/src/lib/exceptions.h
+++ b/src/lib/exceptions.h
@@ -31,6 +31,7 @@
extern "C" {
#include <libavutil/pixfmt.h>
}
+#include <fmt/format.h>
#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
#include <sqlite3.h>
@@ -50,19 +51,19 @@ public:
{}
DecodeError (std::string function, std::string caller)
- : std::runtime_error (String::compose("%1 failed [%2]", function, caller))
+ : std::runtime_error(fmt::format("{} failed [{}]", function, caller))
{}
DecodeError (std::string function, std::string caller, int error)
- : std::runtime_error (String::compose("%1 failed [%2] (%3)", function, caller, error))
+ : std::runtime_error(fmt::format("{} failed [{}] ({})", function, caller, error))
{}
DecodeError (std::string function, std::string caller, boost::filesystem::path file)
- : std::runtime_error (String::compose("%1 failed [%2] (%3)", function, caller, file.string()))
+ : std::runtime_error(fmt::format("{} failed [{}] ({})", function, caller, file.string()))
{}
DecodeError (std::string function, std::string caller, int error, boost::filesystem::path file)
- : std::runtime_error (String::compose("%1 failed [%2] (%3) (%4)", function, caller, error, file.string()))
+ : std::runtime_error(fmt::format("{} failed [{}] ({}) ({})", function, caller, error, file.string()))
{}
};
@@ -86,12 +87,12 @@ public:
: std::runtime_error (s)
{}
- explicit EncodeError (std::string function, std::string caller)
- : std::runtime_error (String::compose("%1 failed [%2]", function, caller))
+ EncodeError(std::string function, std::string caller)
+ : std::runtime_error(fmt::format("{} failed [{}]", function, caller))
{}
- explicit EncodeError (std::string function, std::string caller, int error)
- : std::runtime_error (String::compose("%1 failed [%2] (%3)", function, caller, error))
+ EncodeError(std::string function, std::string caller, int error)
+ : std::runtime_error(fmt::format("{} failed [{}] ({})", function, caller, error))
{}
};
@@ -106,7 +107,7 @@ public:
* @param f Name of the file that this exception concerns.
*/
FileError (std::string m, boost::filesystem::path f)
- : std::runtime_error (String::compose("%1 with %2", m, f.string()))
+ : std::runtime_error(fmt::format("{} with {}", m, f.string()))
, _file (f)
{}
@@ -339,7 +340,7 @@ class CPLNotFoundError : public DCPError
{
public:
CPLNotFoundError(std::string id)
- : DCPError(String::compose("CPL %1 not found", id))
+ : DCPError(fmt::format("CPL {} not found", id))
{}
};
@@ -517,17 +518,17 @@ private:
std::string get_message(sqlite3* db, char const* s)
{
- return String::compose("%1 (in %2)", s, get_filename(db));
+ return fmt::format("{} (in {})", s, get_filename(db).string());
}
std::string get_message(sqlite3* db, int rc)
{
- return String::compose("%1 (in %2)", sqlite3_errstr(rc), get_filename(db));
+ return fmt::format("{} (in {})", sqlite3_errstr(rc), get_filename(db).string());
}
std::string get_message(sqlite3* db, int rc, std::string doing)
{
- return String::compose("%1 (while doing %2) (in %3)", sqlite3_errstr(rc), doing, get_filename(db));
+ return fmt::format("{} (while doing {}) (in {})", sqlite3_errstr(rc), doing, get_filename(db).string());
}
boost::filesystem::path _filename;