Skip to content

Commit

Permalink
common: Fix compatibility with fmt v9
Browse files Browse the repository at this point in the history
  • Loading branch information
StollD committed Feb 21, 2024
1 parent de9c2eb commit e49d55b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/common/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,20 @@ class Error : public std::runtime_error {
/*
* First run the error code through format, to get a string representation.
* This representation might itself be a format string and accept parameters.
*
* NOTE:
*
* This was supposed to be fmt::format("{}", T), but version 9 of the fmt
* library only uses the format_as method when it returns an integer type.
*
* Instead of wasting lines implementing the full blown fmt::formatter type,
* we just call the format_as method here directly, just like fmt would do.
*
* That said I have no idea how this call actually works.
* If you are reading this and wondering where format_as is defined, it is
* next to the enum class holding the error codes.
*/
std::string error = fmt::format("{}", T);
std::string error = format_as(T);

/*
* If we have any parameters, try to format the error string as if it were
Expand Down

0 comments on commit e49d55b

Please sign in to comment.