client/Response: refactor FormatError() to use libfmt

This commit is contained in:
Max Kellermann
2021-05-25 16:11:35 +02:00
parent 18efda719e
commit 0d97eba7a5
6 changed files with 56 additions and 33 deletions

View File

@@ -34,6 +34,8 @@
#include "util/ASCII.hxx"
#include "song/Filter.hxx"
#include <fmt/format.h>
#include <memory>
#include <vector>
@@ -183,8 +185,8 @@ handle_count(Client &client, Request args, Response &r)
const char *s = args[args.size - 1];
group = tag_name_parse_i(s);
if (group == TAG_NUM_OF_ITEM_TYPES) {
r.FormatError(ACK_ERROR_ARG,
"Unknown tag type: %s", s);
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), s);
return CommandResult::ERROR;
}
@@ -252,8 +254,8 @@ handle_list(Client &client, Request args, Response &r)
const auto tagType = tag_name_parse_i(tag_name);
if (tagType == TAG_NUM_OF_ITEM_TYPES) {
r.FormatError(ACK_ERROR_ARG,
"Unknown tag type: %s", tag_name);
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), tag_name);
return CommandResult::ERROR;
}
@@ -266,9 +268,9 @@ handle_list(Client &client, Request args, Response &r)
args.front()[0] != '(') {
/* for compatibility with < 0.12.0 */
if (tagType != TAG_ALBUM) {
r.FormatError(ACK_ERROR_ARG,
"should be \"%s\" for 3 arguments",
tag_item_names[TAG_ALBUM]);
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("should be \"{}\" for 3 arguments"),
tag_item_names[TAG_ALBUM]);
return CommandResult::ERROR;
}
@@ -281,8 +283,8 @@ handle_list(Client &client, Request args, Response &r)
const char *s = args[args.size - 1];
const auto group = tag_name_parse_i(s);
if (group == TAG_NUM_OF_ITEM_TYPES) {
r.FormatError(ACK_ERROR_ARG,
"Unknown tag type: %s", s);
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), s);
return CommandResult::ERROR;
}