lib/fmt/RuntimeError: new library

Replacing FormatRuntimeError().
This commit is contained in:
Max Kellermann
2022-11-28 21:58:21 +01:00
parent 45b13fc2a6
commit fa58db798b
105 changed files with 551 additions and 502 deletions

View File

@@ -37,9 +37,9 @@
#include "tag/Builder.hxx"
#include "tag/Tag.hxx"
#include "tag/ParseName.hxx"
#include "lib/fmt/RuntimeError.hxx"
#include "util/RecursiveMap.hxx"
#include "util/ScopeExit.hxx"
#include "util/RuntimeError.hxx"
#include "protocol/Ack.hxx"
#include "event/SocketEvent.hxx"
#include "event/IdleEvent.hxx"
@@ -507,9 +507,9 @@ ProxyDatabase::Connect()
if (mpd_connection_cmp_server_version(connection, 0, 20, 0) < 0) {
const unsigned *version =
mpd_connection_get_server_version(connection);
throw FormatRuntimeError("Connect to MPD %u.%u.%u, but this "
"plugin requires at least version 0.20",
version[0], version[1], version[2]);
throw FmtRuntimeError("Connect to MPD {}.{}.{}, but this "
"plugin requires at least version 0.20",
version[0], version[1], version[2]);
}
if (!password.empty() &&
@@ -521,8 +521,8 @@ ProxyDatabase::Connect()
std::throw_with_nested(host.empty()
? std::runtime_error("Failed to connect to remote MPD")
: FormatRuntimeError("Failed to connect to remote MPD '%s'",
host.c_str()));
: FmtRuntimeError("Failed to connect to remote MPD '{}'",
host));
}
mpd_connection_set_keepalive(connection, keepalive);

View File

@@ -20,13 +20,13 @@
#include "DatabaseSave.hxx"
#include "db/DatabaseLock.hxx"
#include "DirectorySave.hxx"
#include "lib/fmt/RuntimeError.hxx"
#include "io/BufferedOutputStream.hxx"
#include "io/LineReader.hxx"
#include "tag/ParseName.hxx"
#include "tag/Settings.hxx"
#include "fs/Charset.hxx"
#include "util/StringCompare.hxx"
#include "util/RuntimeError.hxx"
#include "Version.h"
#include <fmt/format.h>
@@ -102,21 +102,21 @@ db_load_internal(LineReader &file, Directory &music_root)
const char *const old_charset = GetFSCharset();
if (*old_charset != 0
&& strcmp(new_charset, old_charset) != 0)
throw FormatRuntimeError("Existing database has charset "
"\"%s\" instead of \"%s\"; "
"discarding database file",
new_charset, old_charset);
throw FmtRuntimeError("Existing database has charset "
"\"{}\" instead of \"{}\"; "
"discarding database file",
new_charset, old_charset);
} else if ((p = StringAfterPrefix(line, DB_TAG_PREFIX))) {
const char *name = p;
TagType tag = tag_name_parse(name);
if (tag == TAG_NUM_OF_ITEM_TYPES)
throw FormatRuntimeError("Unrecognized tag '%s', "
"discarding database file",
name);
throw FmtRuntimeError("Unrecognized tag '{}', "
"discarding database file",
name);
tags[tag] = true;
} else {
throw FormatRuntimeError("Malformed line: %s", line);
throw FmtRuntimeError("Malformed line: {}", line);
}
}

View File

@@ -26,10 +26,10 @@
#include "io/LineReader.hxx"
#include "io/BufferedOutputStream.hxx"
#include "time/ChronoUtil.hxx"
#include "lib/fmt/RuntimeError.hxx"
#include "util/StringAPI.hxx"
#include "util/StringCompare.hxx"
#include "util/NumberParser.hxx"
#include "util/RuntimeError.hxx"
#include <fmt/format.h>
@@ -126,8 +126,7 @@ static Directory *
directory_load_subdir(LineReader &file, Directory &parent, std::string_view name)
{
if (parent.FindChild(name) != nullptr)
throw FormatRuntimeError("Duplicate subdirectory '%.*s'",
int(name.size()), name.data());
throw FmtRuntimeError("Duplicate subdirectory '{}'", name);
Directory *directory = parent.CreateChild(name);
@@ -141,7 +140,7 @@ directory_load_subdir(LineReader &file, Directory &parent, std::string_view name
break;
if (!ParseLine(*directory, line))
throw FormatRuntimeError("Malformed line: %s", line);
throw FmtRuntimeError("Malformed line: {}", line);
}
directory_load(file, *directory);
@@ -167,7 +166,8 @@ directory_load(LineReader &file, Directory &directory)
const char *name = p;
if (directory.FindSong(name) != nullptr)
throw FormatRuntimeError("Duplicate song '%s'", name);
throw FmtRuntimeError("Duplicate song '{}'",
name);
std::string target;
auto detached_song = song_load(file, name,
@@ -182,7 +182,7 @@ directory_load(LineReader &file, Directory &directory)
const char *name = p;
playlist_metadata_load(file, directory.playlists, name);
} else {
throw FormatRuntimeError("Malformed line: %s", line);
throw FmtRuntimeError("Malformed line: {}", line);
}
}
}

View File

@@ -27,7 +27,6 @@
#include "lib/upnp/Error.hxx"
#include "Directory.hxx"
#include "util/NumberParser.hxx"
#include "util/RuntimeError.hxx"
#include "util/ScopeExit.hxx"
#include "util/StringFormat.hxx"