*: let libfmt quote strings

This commit is contained in:
Max Kellermann 2024-04-16 11:06:34 +02:00
parent 39c9e92f42
commit 0c1ecc96a8
71 changed files with 160 additions and 160 deletions

View File

@ -88,7 +88,7 @@ ListenXdgRuntimeDir(ClientListener &listener) noexcept
return true; return true;
} catch (...) { } catch (...) {
FmtError(listen_domain, FmtError(listen_domain,
"Failed to listen on '{}' (not fatal): {}", "Failed to listen on {:?} (not fatal): {}",
socket_path, std::current_exception()); socket_path, std::current_exception());
return false; return false;
} }

View File

@ -63,10 +63,10 @@ log_init_file(int line)
out_fd = open_log_file(); out_fd = open_log_file();
if (out_fd < 0) { if (out_fd < 0) {
#ifdef _WIN32 #ifdef _WIN32
throw FmtRuntimeError("failed to open log file \"{}\" (config line {})", throw FmtRuntimeError("failed to open log file {:?} (config line {})",
out_path, line); out_path, line);
#else #else
throw FmtErrno("failed to open log file \"{}\" (config line {})", throw FmtErrno("failed to open log file {:?} (config line {})",
out_path, line); out_path, line);
#endif #endif
} }
@ -92,7 +92,7 @@ parse_log_level(const char *value)
else if (StringIsEqual(value, "error")) else if (StringIsEqual(value, "error"))
return LogLevel::ERROR; return LogLevel::ERROR;
else else
throw FmtRuntimeError("unknown log level \"{}\"", value); throw FmtRuntimeError("unknown log level {:?}", value);
} }
#endif #endif

View File

@ -49,13 +49,13 @@ PrefetchSong(InputCacheManager &cache, const char *uri) noexcept
if (cache.Contains(uri)) if (cache.Contains(uri))
return; return;
FmtDebug(cache_domain, "Prefetch '{}'", uri); FmtDebug(cache_domain, "Prefetch {:?}", uri);
try { try {
cache.Prefetch(uri); cache.Prefetch(uri);
} catch (...) { } catch (...) {
FmtError(cache_domain, FmtError(cache_domain,
"Prefetch '{}' failed: {}", "Prefetch {:?} failed: {}",
uri, std::current_exception()); uri, std::current_exception());
} }
} }

View File

@ -52,7 +52,7 @@ ParsePermission(std::string_view s)
if (s == i->name) if (s == i->name)
return i->value; return i->value;
throw FmtRuntimeError("unknown permission \"{}\"", s); throw FmtRuntimeError("unknown permission {:?}", s);
} }
static unsigned static unsigned
@ -86,7 +86,7 @@ initPermissions(const ConfigData &config)
const auto [password, permissions] = const auto [password, permissions] =
Split(value, PERMISSION_PASSWORD_CHAR); Split(value, PERMISSION_PASSWORD_CHAR);
if (permissions.data() == nullptr) if (permissions.data() == nullptr)
throw FmtRuntimeError("\"{}\" not found in password string", throw FmtRuntimeError("{:?} not found in password string",
PERMISSION_PASSWORD_CHAR); PERMISSION_PASSWORD_CHAR);
permission_passwords.emplace(password, permission_passwords.emplace(password,

View File

@ -47,7 +47,7 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept
item->scanner->Start(); item->scanner->Start();
} catch (...) { } catch (...) {
FmtError(remote_tag_cache_domain, FmtError(remote_tag_cache_domain,
"Failed to scan tags of '{}': {}", "Failed to scan tags of {:?}: {}",
uri, std::current_exception()); uri, std::current_exception());
item->scanner.reset(); item->scanner.reset();
@ -113,7 +113,7 @@ void
RemoteTagCache::Item::OnRemoteTagError(std::exception_ptr e) noexcept RemoteTagCache::Item::OnRemoteTagError(std::exception_ptr e) noexcept
{ {
FmtError(remote_tag_cache_domain, FmtError(remote_tag_cache_domain,
"Failed to scan tags of '{}': {}", uri, e); "Failed to scan tags of {:?}: {}", uri, e);
scanner.reset(); scanner.reset();

View File

@ -27,7 +27,7 @@ struct ZzipDir {
explicit ZzipDir(Path path) explicit ZzipDir(Path path)
:dir(zzip_dir_open(NarrowPath(path), nullptr)) { :dir(zzip_dir_open(NarrowPath(path), nullptr)) {
if (dir == nullptr) if (dir == nullptr)
throw FmtRuntimeError("Failed to open ZIP file {}", throw FmtRuntimeError("Failed to open ZIP file {:?}",
path); path);
} }
@ -120,11 +120,11 @@ ZzipArchiveFile::OpenStream(const char *pathname,
const auto error = (zzip_error_t)zzip_error(dir->dir); const auto error = (zzip_error_t)zzip_error(dir->dir);
switch (error) { switch (error) {
case ZZIP_ENOENT: case ZZIP_ENOENT:
throw FmtFileNotFound("Failed to open '{}' in ZIP file", throw FmtFileNotFound("Failed to open {:?} in ZIP file",
pathname); pathname);
default: default:
throw FmtRuntimeError("Failed to open '{}' in ZIP file: {}", throw FmtRuntimeError("Failed to open {:?} in ZIP file: {}",
pathname, pathname,
zzip_strerror(error)); zzip_strerror(error));
} }
@ -145,7 +145,7 @@ ZzipInputStream::Read(std::unique_lock<Mutex> &, void *ptr, size_t read_size)
throw std::runtime_error("zzip_file_read() has failed"); throw std::runtime_error("zzip_file_read() has failed");
if (nbytes == 0 && !IsEOF()) if (nbytes == 0 && !IsEOF())
throw FmtRuntimeError("Unexpected end of file {} at {} of {}", throw FmtRuntimeError("Unexpected end of file {:?} at {} of {}",
GetURI(), GetOffset(), GetSize()); GetURI(), GetOffset(), GetSize());
offset = zzip_tell(file); offset = zzip_tell(file);

View File

@ -22,7 +22,7 @@ Client::ProcessCommandList(bool list_ok,
for (auto &&i : list) { for (auto &&i : list) {
char *cmd = &*i.begin(); char *cmd = &*i.begin();
FmtDebug(client_domain, "process command \"{}\"", cmd); FmtDebug(client_domain, "process command {:?}", cmd);
auto ret = command_process(*this, n++, cmd); auto ret = command_process(*this, n++, cmd);
FmtDebug(client_domain, "command returned {}", unsigned(ret)); FmtDebug(client_domain, "command returned {}", unsigned(ret));
if (IsExpired()) if (IsExpired())
@ -46,7 +46,7 @@ Client::ProcessLine(char *line) noexcept
letter; this could be a badly routed HTTP letter; this could be a badly routed HTTP
request */ request */
FmtWarning(client_domain, FmtWarning(client_domain,
"[{}] malformed command \"{}\"", "[{}] malformed command {:?}",
num, line); num, line);
return CommandResult::CLOSE; return CommandResult::CLOSE;
} }
@ -67,7 +67,7 @@ Client::ProcessLine(char *line) noexcept
/* during idle mode, clients must not send anything /* during idle mode, clients must not send anything
except "noidle" */ except "noidle" */
FmtWarning(client_domain, FmtWarning(client_domain,
"[{}] command \"{}\" during idle", "[{}] command {:?} during idle",
num, line); num, line);
return CommandResult::CLOSE; return CommandResult::CLOSE;
} }
@ -116,7 +116,7 @@ Client::ProcessLine(char *line) noexcept
const unsigned id = num; const unsigned id = num;
FmtDebug(client_domain, FmtDebug(client_domain,
"[{}] process command \"{}\"", "[{}] process command {:?}",
id, line); id, line);
auto ret = command_process(*this, 0, line); auto ret = command_process(*this, 0, line);
FmtDebug(client_domain, FmtDebug(client_domain,

View File

@ -320,7 +320,7 @@ command_check_request(const struct command *cmd, Response &r,
{ {
if (cmd->permission != (permission & cmd->permission)) { if (cmd->permission != (permission & cmd->permission)) {
r.FmtError(ACK_ERROR_PERMISSION, r.FmtError(ACK_ERROR_PERMISSION,
FMT_STRING("you don't have permission for \"{}\""), FMT_STRING("you don't have permission for {:?}"),
cmd->cmd); cmd->cmd);
return false; return false;
} }
@ -333,17 +333,17 @@ command_check_request(const struct command *cmd, Response &r,
if (min == max && unsigned(max) != args.size()) { if (min == max && unsigned(max) != args.size()) {
r.FmtError(ACK_ERROR_ARG, r.FmtError(ACK_ERROR_ARG,
FMT_STRING("wrong number of arguments for \"{}\""), FMT_STRING("wrong number of arguments for {:?}"),
cmd->cmd); cmd->cmd);
return false; return false;
} else if (args.size() < unsigned(min)) { } else if (args.size() < unsigned(min)) {
r.FmtError(ACK_ERROR_ARG, r.FmtError(ACK_ERROR_ARG,
FMT_STRING("too few arguments for \"{}\""), FMT_STRING("too few arguments for {:?}"),
cmd->cmd); cmd->cmd);
return false; return false;
} else if (max >= 0 && args.size() > unsigned(max)) { } else if (max >= 0 && args.size() > unsigned(max)) {
r.FmtError(ACK_ERROR_ARG, r.FmtError(ACK_ERROR_ARG,
FMT_STRING("too many arguments for \"{}\""), FMT_STRING("too many arguments for {:?}"),
cmd->cmd); cmd->cmd);
return false; return false;
} else } else
@ -357,7 +357,7 @@ command_checked_lookup(Response &r, unsigned permission,
const struct command *cmd = command_lookup(cmd_name); const struct command *cmd = command_lookup(cmd_name);
if (cmd == nullptr) { if (cmd == nullptr) {
r.FmtError(ACK_ERROR_UNKNOWN, r.FmtError(ACK_ERROR_UNKNOWN,
FMT_STRING("unknown command \"{}\""), cmd_name); FMT_STRING("unknown command {:?}"), cmd_name);
return nullptr; return nullptr;
} }

View File

@ -325,7 +325,7 @@ handle_list(Client &client, Request args, Response &r)
/* for compatibility with < 0.12.0 */ /* for compatibility with < 0.12.0 */
if (tagType != TAG_ALBUM) { if (tagType != TAG_ALBUM) {
r.FmtError(ACK_ERROR_ARG, r.FmtError(ACK_ERROR_ARG,
FMT_STRING("should be \"{}\" for 3 arguments"), FMT_STRING("should be {:?} for 3 arguments"),
tag_item_names[TAG_ALBUM]); tag_item_names[TAG_ALBUM]);
return CommandResult::ERROR; return CommandResult::ERROR;
} }

View File

@ -38,7 +38,7 @@ public:
ValidateUri(uri).c_str(), ValidateUri(uri).c_str(),
name); name);
if (value.empty()) { if (value.empty()) {
response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: \"{}\"", name); response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: {:?}", name);
return CommandResult::ERROR; return CommandResult::ERROR;
} }
@ -63,7 +63,7 @@ public:
? sticker_database.Delete(sticker_type, uri) ? sticker_database.Delete(sticker_type, uri)
: sticker_database.DeleteValue(sticker_type, uri, name); : sticker_database.DeleteValue(sticker_type, uri, name);
if (!ret) { if (!ret) {
response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: \"{}\"", name); response.FmtError(ACK_ERROR_NO_EXIST, "no such sticker: {:?}", name);
return CommandResult::ERROR; return CommandResult::ERROR;
} }
@ -247,13 +247,13 @@ public:
protected: protected:
std::string ValidateUri(const char *uri) override { std::string ValidateUri(const char *uri) override {
if (tag_type == TAG_NUM_OF_ITEM_TYPES) if (tag_type == TAG_NUM_OF_ITEM_TYPES)
throw std::invalid_argument(fmt::format("no such tag: \"{}\"", sticker_type)); throw std::invalid_argument(fmt::format("no such tag: {:?}", sticker_type));
if (!sticker_allowed_tags.Test(tag_type)) if (!sticker_allowed_tags.Test(tag_type))
throw std::invalid_argument(fmt::format("unsupported tag: \"{}\"", sticker_type)); throw std::invalid_argument(fmt::format("unsupported tag: {:?}", sticker_type));
if (!TagExists(database, tag_type, uri)) if (!TagExists(database, tag_type, uri))
throw std::invalid_argument(fmt::format("no such {}: \"{}\"", sticker_type, uri)); throw std::invalid_argument(fmt::format("no such {}: {:?}", sticker_type, uri));
return {uri}; return {uri};
} }
@ -283,7 +283,7 @@ protected:
auto normalized = filter.ToExpression(); auto normalized = filter.ToExpression();
if (!FilterMatches(database, filter)) if (!FilterMatches(database, filter))
throw std::invalid_argument(fmt::format("no matches found: \"{}\"", normalized)); throw std::invalid_argument(fmt::format("no matches found: {:?}", normalized));
return normalized; return normalized;
} }
@ -306,7 +306,7 @@ private:
const ScopeDatabaseLock protect; const ScopeDatabaseLock protect;
if (!playlists.exists(uri)) if (!playlists.exists(uri))
throw std::invalid_argument(fmt::format("no such playlist: \"{}\"", uri)); throw std::invalid_argument(fmt::format("no such playlist: {:?}", uri));
return {uri}; return {uri};
} }
@ -369,7 +369,7 @@ handle_sticker(Client &client, Request args, Response &r)
handler = std::make_unique<TagHandler>(r, db, sticker_database, tag_type); handler = std::make_unique<TagHandler>(r, db, sticker_database, tag_type);
else { else {
r.FmtError(ACK_ERROR_ARG, "unknown sticker domain \"{}\"", sticker_type); r.FmtError(ACK_ERROR_ARG, "unknown sticker domain {:?}", sticker_type);
return CommandResult::ERROR; return CommandResult::ERROR;
} }
@ -413,7 +413,7 @@ handle_sticker(Client &client, Request args, Response &r)
sort = s; sort = s;
} }
else { else {
r.FmtError(ACK_ERROR_ARG, "Unknown sort tag \"{}\"", s); r.FmtError(ACK_ERROR_ARG, "Unknown sort tag {:?}", s);
return CommandResult::ERROR; return CommandResult::ERROR;
} }
@ -444,7 +444,7 @@ handle_sticker(Client &client, Request args, Response &r)
else if (StringIsEqual(op_s, "starts_with")) else if (StringIsEqual(op_s, "starts_with"))
op = StickerOperator::STARTS_WITH; op = StickerOperator::STARTS_WITH;
else { else {
r.FmtError(ACK_ERROR_ARG, "bad operator \"{}\"", op_s); r.FmtError(ACK_ERROR_ARG, "bad operator {:?}", op_s);
return CommandResult::ERROR; return CommandResult::ERROR;
} }
} }

View File

@ -12,7 +12,7 @@
void void
BlockParam::ThrowWithNested() const BlockParam::ThrowWithNested() const
{ {
std::throw_with_nested(FmtRuntimeError("Error in setting \"{}\" on line {}", std::throw_with_nested(FmtRuntimeError("Error in setting {:?} on line {}",
name, line)); name, line));
} }

View File

@ -18,7 +18,7 @@ Check(const ConfigBlock &block)
for (const auto &i : block.block_params) { for (const auto &i : block.block_params) {
if (!i.used) if (!i.used)
FmtWarning(config_domain, FmtWarning(config_domain,
"option '{}' on line {} was not recognized", "option {:?} on line {} was not recognized",
i.name, i.line); i.name, i.line);
} }
} }

View File

@ -141,7 +141,7 @@ ConfigData::FindBlock(ConfigBlockOption option,
for (const auto &block : GetBlockList(option)) { for (const auto &block : GetBlockList(option)) {
const char *value2 = block.GetBlockValue(key); const char *value2 = block.GetBlockValue(key);
if (value2 == nullptr) if (value2 == nullptr)
throw FmtRuntimeError("block without '{}' in line {}", throw FmtRuntimeError("block without {:?} in line {}",
key, block.line); key, block.line);
if (StringIsEqual(value2, value)) if (StringIsEqual(value2, value))

View File

@ -54,7 +54,7 @@ config_read_name_value(ConfigBlock &block, char *input, unsigned line)
const BlockParam *bp = block.GetBlockParam(name); const BlockParam *bp = block.GetBlockParam(name);
if (bp != nullptr) if (bp != nullptr)
throw FmtRuntimeError("\"{}\" is duplicate, first defined on line {}", throw FmtRuntimeError("{:?} is duplicate, first defined on line {}",
name, bp->line); name, bp->line);
block.AddBlockParam(name, value, line); block.AddBlockParam(name, value, line);
@ -102,12 +102,12 @@ ReadConfigBlock(ConfigData &config_data, BufferedReader &reader,
if (option.deprecated) if (option.deprecated)
FmtWarning(config_file_domain, FmtWarning(config_file_domain,
"config parameter \"{}\" on line {} is deprecated", "config parameter {:?} on line {} is deprecated",
name, reader.GetLineNumber()); name, reader.GetLineNumber());
if (!option.repeatable) if (!option.repeatable)
if (const auto *block = config_data.GetBlock(o)) if (const auto *block = config_data.GetBlock(o))
throw FmtRuntimeError("config parameter \"{}\" is first defined " throw FmtRuntimeError("config parameter {:?} is first defined "
"on line {} and redefined on line {}", "on line {} and redefined on line {}",
name, block->line, name, block->line,
reader.GetLineNumber()); reader.GetLineNumber());
@ -134,7 +134,7 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
if (option.deprecated) if (option.deprecated)
FmtWarning(config_file_domain, FmtWarning(config_file_domain,
"config parameter \"{}\" on line {} is deprecated", "config parameter {:?} on line {} is deprecated",
name, reader.GetLineNumber()); name, reader.GetLineNumber());
if (!option.repeatable) if (!option.repeatable)

View File

@ -20,7 +20,7 @@ ParseBool(const char *value)
if (StringArrayContainsCase(f, value)) if (StringArrayContainsCase(f, value))
return false; return false;
throw FmtRuntimeError(R"(Not a valid boolean ("yes" or "no"): "{}")", value); throw FmtRuntimeError(R"(Not a valid boolean ("yes" or "no"): {:?})", value);
} }
long long

View File

@ -22,7 +22,7 @@ GetBufferChunks(const ConfigData &config)
buffer_size = param->With([](const char *s){ buffer_size = param->With([](const char *s){
size_t result = ParseSize(s, KILOBYTE); size_t result = ParseSize(s, KILOBYTE);
if (result <= 0) if (result <= 0)
throw FmtRuntimeError("buffer size \"{}\" is not a " throw FmtRuntimeError("buffer size {:?} is not a "
"positive integer", s); "positive integer", s);
if (result < MIN_BUFFER_SIZE) { if (result < MIN_BUFFER_SIZE) {
@ -37,7 +37,7 @@ GetBufferChunks(const ConfigData &config)
unsigned buffer_chunks = buffer_size / CHUNK_SIZE; unsigned buffer_chunks = buffer_size / CHUNK_SIZE;
if (buffer_chunks >= 1 << 15) if (buffer_chunks >= 1 << 15)
throw FmtRuntimeError("buffer size \"{}\" is too big", throw FmtRuntimeError("buffer size {:?} is too big",
buffer_size); buffer_size);
return buffer_chunks; return buffer_chunks;

View File

@ -19,14 +19,14 @@ DatabaseGlobalInit(EventLoop &main_event_loop,
const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name); const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name);
if (plugin == nullptr) if (plugin == nullptr)
throw FmtRuntimeError("No such database plugin: {}", throw FmtRuntimeError("No such database plugin: {:?}",
plugin_name); plugin_name);
try { try {
return plugin->create(main_event_loop, io_event_loop, return plugin->create(main_event_loop, io_event_loop,
listener, block); listener, block);
} catch (...) { } catch (...) {
std::throw_with_nested(FmtRuntimeError("Failed to initialize database plugin '{}'", std::throw_with_nested(FmtRuntimeError("Failed to initialize database plugin {:?}",
plugin_name)); plugin_name));
} }
} }

View File

@ -453,7 +453,7 @@ ProxyDatabase::Connect()
std::throw_with_nested(host.empty() std::throw_with_nested(host.empty()
? std::runtime_error("Failed to connect to remote MPD") ? std::runtime_error("Failed to connect to remote MPD")
: FmtRuntimeError("Failed to connect to remote MPD '{}'", : FmtRuntimeError("Failed to connect to remote MPD {:?}",
host)); host));
} }

View File

@ -90,7 +90,7 @@ db_load_internal(LineReader &file, Directory &music_root,
if (*old_charset != 0 if (*old_charset != 0
&& strcmp(new_charset, old_charset) != 0) && strcmp(new_charset, old_charset) != 0)
throw FmtRuntimeError("Existing database has charset " throw FmtRuntimeError("Existing database has charset "
"\"{}\" instead of \"{}\"; " "{:?} instead of {:?}; "
"discarding database file", "discarding database file",
new_charset, old_charset); new_charset, old_charset);
} else if ((p = StringAfterPrefix(line, DB_TAG_PREFIX))) { } else if ((p = StringAfterPrefix(line, DB_TAG_PREFIX))) {
@ -100,13 +100,13 @@ db_load_internal(LineReader &file, Directory &music_root,
const char *name = p; const char *name = p;
TagType tag = tag_name_parse(name); TagType tag = tag_name_parse(name);
if (tag == TAG_NUM_OF_ITEM_TYPES) if (tag == TAG_NUM_OF_ITEM_TYPES)
throw FmtRuntimeError("Unrecognized tag '{}', " throw FmtRuntimeError("Unrecognized tag {:?}, "
"discarding database file", "discarding database file",
name); name);
tags[tag] = true; tags[tag] = true;
} else { } else {
throw FmtRuntimeError("Malformed line: {}", line); throw FmtRuntimeError("Malformed line: {:?}", line);
} }
} }

View File

@ -124,7 +124,7 @@ directory_load_subdir(LineReader &file, Directory &parent, std::string_view name
break; break;
if (!ParseLine(*directory, line)) if (!ParseLine(*directory, line))
throw FmtRuntimeError("Malformed line: {}", line); throw FmtRuntimeError("Malformed line: {:?}", line);
} }
directory_load(file, *directory); directory_load(file, *directory);
@ -153,7 +153,7 @@ directory_load(LineReader &file, Directory &directory)
const std::string_view name = child->GetName(); const std::string_view name = child->GetName();
if (!children.emplace(name).second) if (!children.emplace(name).second)
throw FmtRuntimeError("Duplicate subdirectory '{}'", name); throw FmtRuntimeError("Duplicate subdirectory {:?}", name);
} else if ((p = StringAfterPrefix(line, SONG_BEGIN))) { } else if ((p = StringAfterPrefix(line, SONG_BEGIN))) {
const char *name = p; const char *name = p;
@ -168,7 +168,7 @@ directory_load(LineReader &file, Directory &directory)
song->in_playlist = in_playlist; song->in_playlist = in_playlist;
if (!songs.emplace(song->filename).second) if (!songs.emplace(song->filename).second)
throw FmtRuntimeError("Duplicate song '{}'", throw FmtRuntimeError("Duplicate song {:?}",
name); name);
directory.AddSong(std::move(song)); directory.AddSong(std::move(song));
@ -176,7 +176,7 @@ directory_load(LineReader &file, Directory &directory)
const char *name = p; const char *name = p;
playlist_metadata_load(file, directory.playlists, name); playlist_metadata_load(file, directory.playlists, name);
} else { } else {
throw FmtRuntimeError("Malformed line: {}", line); throw FmtRuntimeError("Malformed line: {:?}", line);
} }
} }
} }

View File

@ -109,7 +109,7 @@ SimpleDatabase::Check() const
#ifndef _WIN32 #ifndef _WIN32
/* Check if we can write to the directory */ /* Check if we can write to the directory */
if (!CheckAccess(dirPath, X_OK | W_OK)) if (!CheckAccess(dirPath, X_OK | W_OK))
throw FmtErrno("Can't create db file in \"{}\"", dirPath); throw FmtErrno("Can't create db file in {:?}", dirPath);
#endif #endif
return; return;
@ -124,7 +124,7 @@ SimpleDatabase::Check() const
#ifndef _WIN32 #ifndef _WIN32
/* And check that we can write to it */ /* And check that we can write to it */
if (!CheckAccess(path, R_OK | W_OK)) if (!CheckAccess(path, R_OK | W_OK))
throw FmtErrno("Can't open db file \"{}\" for reading/writing", throw FmtErrno("Can't open db file {:?} for reading/writing",
path); path);
#endif #endif
} }

View File

@ -40,13 +40,13 @@ InotifyQueue::OnDelay() noexcept
} }
} catch (...) { } catch (...) {
FmtError(update_domain, FmtError(update_domain,
"Failed to enqueue '{}': {}", "Failed to enqueue {:?}: {}",
uri_utf8, std::current_exception()); uri_utf8, std::current_exception());
queue.pop_front(); queue.pop_front();
continue; continue;
} }
FmtDebug(inotify_domain, "updating '{}' job={}", FmtDebug(inotify_domain, "updating {:?} job={}",
uri_utf8, id); uri_utf8, id);
queue.pop_front(); queue.pop_front();

View File

@ -67,7 +67,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
const auto uri_utf8 = storage.MapUTF8(directory->GetPath()); const auto uri_utf8 = storage.MapUTF8(directory->GetPath());
FmtDebug(update_domain, "scanning playlist '{}'", uri_utf8); FmtDebug(update_domain, "scanning playlist {:?}", uri_utf8);
try { try {
Mutex mutex; Mutex mutex;
@ -85,7 +85,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
editor.LockDeleteDirectory(directory); editor.LockDeleteDirectory(directory);
} catch (...) { } catch (...) {
FmtError(update_domain, FmtError(update_domain,
"Failed to scan playlist '{}': {}", "Failed to scan playlist {:?}: {}",
uri_utf8, std::current_exception()); uri_utf8, std::current_exception());
editor.LockDeleteDirectory(directory); editor.LockDeleteDirectory(directory);
} }

View File

@ -145,10 +145,10 @@ decoder_plugin_init_all(const ConfigData &config)
decoder_plugins_enabled[i] = true; decoder_plugins_enabled[i] = true;
} catch (const PluginUnavailable &e) { } catch (const PluginUnavailable &e) {
FmtError(decoder_domain, FmtError(decoder_domain,
"Decoder plugin '{}' is unavailable: {}", "Decoder plugin {:?} is unavailable: {}",
plugin.name, std::current_exception()); plugin.name, std::current_exception());
} catch (...) { } catch (...) {
std::throw_with_nested(FmtRuntimeError("Failed to initialize decoder plugin '{}'", std::throw_with_nested(FmtRuntimeError("Failed to initialize decoder plugin {:?}",
plugin.name)); plugin.name));
} }
} }

View File

@ -481,7 +481,7 @@ FfmpegDecode(DecoderClient &client, InputStream *input,
const AVCodecDescriptor *codec_descriptor = const AVCodecDescriptor *codec_descriptor =
avcodec_descriptor_get(codec_params.codec_id); avcodec_descriptor_get(codec_params.codec_id);
if (codec_descriptor != nullptr) if (codec_descriptor != nullptr)
FmtDebug(ffmpeg_domain, "codec '{}'", FmtDebug(ffmpeg_domain, "codec {:?}",
codec_descriptor->name); codec_descriptor->name);
const AVCodec *codec = avcodec_find_decoder(codec_params.codec_id); const AVCodec *codec = avcodec_find_decoder(codec_params.codec_id);
@ -590,10 +590,10 @@ ffmpeg_decode(DecoderClient &client, InputStream &input)
const auto *input_format = format_context->iformat; const auto *input_format = format_context->iformat;
if (input_format->long_name == nullptr) if (input_format->long_name == nullptr)
FmtDebug(ffmpeg_domain, "detected input format '{}'", FmtDebug(ffmpeg_domain, "detected input format {:?}",
input_format->name); input_format->name);
else else
FmtDebug(ffmpeg_domain, "detected input format '{}' ({})", FmtDebug(ffmpeg_domain, "detected input format {:?} ({:?})",
input_format->name, input_format->long_name); input_format->name, input_format->long_name);
FfmpegDecode(client, &input, *format_context); FfmpegDecode(client, &input, *format_context);
@ -665,10 +665,10 @@ ffmpeg_uri_decode(DecoderClient &client, const char *uri)
const auto *input_format = format_context->iformat; const auto *input_format = format_context->iformat;
if (input_format->long_name == nullptr) if (input_format->long_name == nullptr)
FmtDebug(ffmpeg_domain, "detected input format '{}'", FmtDebug(ffmpeg_domain, "detected input format {:?}",
input_format->name); input_format->name);
else else
FmtDebug(ffmpeg_domain, "detected input format '{}' ({})", FmtDebug(ffmpeg_domain, "detected input format {:?} ({:?})",
input_format->name, input_format->long_name); input_format->name, input_format->long_name);
FfmpegDecode(client, nullptr, *format_context); FfmpegDecode(client, nullptr, *format_context);

View File

@ -142,7 +142,7 @@ gme_file_decode(DecoderClient &client, Path path_fs)
AtScopeExit(emu) { gme_delete(emu); }; AtScopeExit(emu) { gme_delete(emu); };
FmtDebug(gme_domain, "emulator type '{}'", FmtDebug(gme_domain, "emulator type {:?}",
gme_type_system(gme_type(emu))); gme_type_system(gme_type(emu)));
if (gme_accuracy >= 0) if (gme_accuracy >= 0)

View File

@ -529,7 +529,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept
&lame->version.major, &lame->version.minor) != 2) &lame->version.major, &lame->version.minor) != 2)
return false; return false;
FmtDebug(mad_domain, "detected LAME version {}.{} (\"{}\")", FmtDebug(mad_domain, "detected LAME version {}.{} ({:?})",
lame->version.major, lame->version.minor, lame->encoder); lame->version.major, lame->version.minor, lame->encoder);
/* The reference volume was changed from the 83dB used in the /* The reference volume was changed from the 83dB used in the

View File

@ -62,7 +62,7 @@ static void loadRom(const Path rom_path, uint8_t *dump)
{ {
FileReader romDump(rom_path); FileReader romDump(rom_path);
if (romDump.Read(std::as_writable_bytes(std::span{dump, rom_size})) != rom_size) if (romDump.Read(std::as_writable_bytes(std::span{dump, rom_size})) != rom_size)
throw FmtRuntimeError("Could not load rom dump '{}'", rom_path); throw FmtRuntimeError("Could not load rom dump {:?}", rom_path);
} }
/** /**
@ -74,7 +74,7 @@ sidplay_load_songlength_db(const Path path)
auto db = std::make_unique<SidDatabase>(); auto db = std::make_unique<SidDatabase>();
bool error = !db->open(path.c_str()); bool error = !db->open(path.c_str());
if (error) if (error)
throw FmtRuntimeError("unable to read songlengths file {}: {}", throw FmtRuntimeError("unable to read songlengths file {:?}: {}",
path, db->error()); path, db->error());
return db; return db;

View File

@ -41,7 +41,7 @@ WavpackOpenInput(Path path, int flags, int norm_offset)
auto wpc = WavpackOpenFileInput(np, error, auto wpc = WavpackOpenFileInput(np, error,
flags, norm_offset); flags, norm_offset);
if (wpc == nullptr) if (wpc == nullptr)
throw FmtRuntimeError("failed to open WavPack file \"{}\": {}", throw FmtRuntimeError("failed to open WavPack file {:?}: {}",
path, error); path, error);
return wpc; return wpc;

View File

@ -63,7 +63,7 @@ PreparedLameEncoder::PreparedLameEncoder(const ConfigBlock &block)
quality = float(ParseDouble(value, &endptr)); quality = float(ParseDouble(value, &endptr));
if (*endptr != '\0' || quality < -1.0f || quality > 10.0f) if (*endptr != '\0' || quality < -1.0f || quality > 10.0f)
throw FmtRuntimeError("quality \"{}\" is not a number in the " throw FmtRuntimeError("quality {:?} is not a number in the "
"range -1 to 10", "range -1 to 10",
value); value);

View File

@ -80,7 +80,7 @@ PreparedTwolameEncoder::PreparedTwolameEncoder(const ConfigBlock &block)
quality = float(ParseDouble(value, &endptr)); quality = float(ParseDouble(value, &endptr));
if (*endptr != '\0' || quality < -1.0f || quality > 10.0f) if (*endptr != '\0' || quality < -1.0f || quality > 10.0f)
throw FmtRuntimeError("quality \"{}\" is not a number in the " throw FmtRuntimeError("quality {:?} is not a number in the "
"range -1 to 10", "range -1 to 10",
value); value);

View File

@ -73,7 +73,7 @@ PreparedVorbisEncoder::PreparedVorbisEncoder(const ConfigBlock &block)
quality = ParseDouble(value, &endptr); quality = ParseDouble(value, &endptr);
if (*endptr != '\0' || quality < -1.0f || quality > 10.0f) if (*endptr != '\0' || quality < -1.0f || quality > 10.0f)
throw FmtRuntimeError("quality \"{}\" is not a number in the " throw FmtRuntimeError("quality {:?} is not a number in the "
"range -1 to 10", "range -1 to 10",
value); value);

View File

@ -35,7 +35,7 @@ PreparedTwoFilters::Open(AudioFormat &audio_format)
auto b = second->Open(b_in_format); auto b = second->Open(b_in_format);
if (b_in_format != a_out_format) if (b_in_format != a_out_format)
throw FmtRuntimeError("Audio format not supported by filter '{}': {}", throw FmtRuntimeError("Audio format not supported by filter {:?}: {}",
second_name, a_out_format); second_name, a_out_format);
return std::make_unique<TwoFilters>(std::move(a), return std::make_unique<TwoFilters>(std::move(a),

View File

@ -55,16 +55,16 @@ input_stream_global_init(const ConfigData &config, EventLoop &event_loop)
input_plugins_enabled[i] = true; input_plugins_enabled[i] = true;
} catch (const PluginUnconfigured &e) { } catch (const PluginUnconfigured &e) {
FmtDebug(input_domain, FmtDebug(input_domain,
"Input plugin '{}' is not configured: {}", "Input plugin {:?} is not configured: {}",
plugin->name, e.what()); plugin->name, e.what());
continue; continue;
} catch (const PluginUnavailable &e) { } catch (const PluginUnavailable &e) {
FmtDebug(input_domain, FmtDebug(input_domain,
"Input plugin '{}' is unavailable: {}", "Input plugin {:?} is unavailable: {}",
plugin->name, e.what()); plugin->name, e.what());
continue; continue;
} catch (...) { } catch (...) {
std::throw_with_nested(FmtRuntimeError("Failed to initialize input plugin '{}'", std::throw_with_nested(FmtRuntimeError("Failed to initialize input plugin {:?}",
plugin->name)); plugin->name));
} }
} }

View File

@ -256,13 +256,13 @@ AlsaInputStream::Recover(int err)
switch(err) { switch(err) {
case -EPIPE: case -EPIPE:
FmtDebug(alsa_input_domain, FmtDebug(alsa_input_domain,
"Overrun on ALSA capture device \"{}\"", "Overrun on ALSA capture device {:?}",
device); device);
break; break;
case -ESTRPIPE: case -ESTRPIPE:
FmtDebug(alsa_input_domain, FmtDebug(alsa_input_domain,
"ALSA capture device \"{}\" was suspended", "ALSA capture device {:?} was suspended",
device); device);
break; break;
} }

View File

@ -28,7 +28,7 @@ OpenArchiveInputStream(Path path, Mutex &mutex)
} }
} catch (...) { } catch (...) {
FmtDebug(input_domain, FmtDebug(input_domain,
"not an archive, lookup '{}' failed: {}", "not an archive, lookup {:?} failed: {}",
path, std::current_exception()); path, std::current_exception());
return nullptr; return nullptr;
} }

View File

@ -17,7 +17,7 @@ RequireFilterByName(const char *name)
{ {
const auto *filter = avfilter_get_by_name(name); const auto *filter = avfilter_get_by_name(name);
if (filter == nullptr) if (filter == nullptr)
throw FmtRuntimeError("No such FFmpeg filter: '{}'", name); throw FmtRuntimeError("No such FFmpeg filter: {:?}", name);
return *filter; return *filter;
} }

View File

@ -41,7 +41,7 @@ IcuConverter::Create(const char *charset)
UConverter *converter = ucnv_open(charset, &code); UConverter *converter = ucnv_open(charset, &code);
if (converter == nullptr) if (converter == nullptr)
throw ICU::MakeError(code, throw ICU::MakeError(code,
FmtBuffer<256>(FMT_STRING("Failed to initialize charset '{}'"), FmtBuffer<256>(FMT_STRING("Failed to initialize charset {:?}"),
charset)); charset));
return std::unique_ptr<IcuConverter>(new IcuConverter(converter)); return std::unique_ptr<IcuConverter>(new IcuConverter(converter));
@ -54,7 +54,7 @@ IcuConverter::Create(const char *charset)
iconv_close(to); iconv_close(to);
if (from != (iconv_t)-1) if (from != (iconv_t)-1)
iconv_close(from); iconv_close(from);
throw FmtErrno(e, FMT_STRING("Failed to initialize charset '{}'"), throw FmtErrno(e, FMT_STRING("Failed to initialize charset {:?}"),
charset); charset);
} }

View File

@ -12,7 +12,7 @@ Database::Database(const char *path)
int result = sqlite3_open(path, &db); int result = sqlite3_open(path, &db);
if (result != SQLITE_OK) if (result != SQLITE_OK)
throw SqliteError(db, result, throw SqliteError(db, result,
FmtBuffer<1024>("Failed to open sqlite database '{}'", FmtBuffer<1024>("Failed to open sqlite database {:?}",
path)); path));
} }

View File

@ -33,7 +33,7 @@ output_mixer_get_volume(const AudioOutputControl &ao) noexcept
return mixer->LockGetVolume(); return mixer->LockGetVolume();
} catch (...) { } catch (...) {
FmtError(mixer_domain, FmtError(mixer_domain,
"Failed to read mixer for '{}': {}", "Failed to read mixer for {:?}: {}",
ao.GetName(), std::current_exception()); ao.GetName(), std::current_exception());
return -1; return -1;
} }
@ -88,9 +88,9 @@ output_mixer_set_volume(AudioOutputControl &ao, unsigned volume)
return SetVolumeResult::OK; return SetVolumeResult::OK;
} catch (...) { } catch (...) {
FmtError(mixer_domain, FmtError(mixer_domain,
"Failed to set mixer for '{}': {}", "Failed to set mixer for {:?}: {}",
ao.GetName(), std::current_exception()); ao.GetName(), std::current_exception());
std::throw_with_nested(std::runtime_error(FmtBuffer<256>("Failed to set mixer for '{}'", std::throw_with_nested(std::runtime_error(FmtBuffer<256>("Failed to set mixer for {:?}",
ao.GetName()))); ao.GetName())));
} }
} }

View File

@ -108,7 +108,7 @@ OssMixer::Open()
throw MakeErrno("READ_DEVMASK failed"); throw MakeErrno("READ_DEVMASK failed");
if (((1 << volume_control) & devmask) == 0) if (((1 << volume_control) & devmask) == 0)
throw FmtErrno("mixer control \"{}\" not usable", throw FmtErrno("mixer control {:?} not usable",
control); control);
} }
} catch (...) { } catch (...) {
@ -134,8 +134,8 @@ OssMixer::GetVolume()
if (left != right) { if (left != right) {
FmtWarning(oss_mixer_domain, FmtWarning(oss_mixer_domain,
"volume for left and right is not the same, \"{}\" and " "volume for left and right is not the same, {:?} and "
"\"{}\"\n", left, right); "{:?}\n", left, right);
} }
return left; return left;

View File

@ -161,7 +161,7 @@ parse_volume_scale_factor(const char *value) {
float factor = ParseFloat(value, &endptr); float factor = ParseFloat(value, &endptr);
if (endptr == value || *endptr != '\0' || factor < 0.5f || factor > 5.0f) if (endptr == value || *endptr != '\0' || factor < 0.5f || factor > 5.0f)
throw FmtRuntimeError("\"{}\" is not a number in the " throw FmtRuntimeError("{:?} is not a number in the "
"range 0.5 to 5.0", "range 0.5 to 5.0",
value); value);

View File

@ -22,7 +22,7 @@ CreateNeighborExplorer(EventLoop &loop, NeighborListener &listener,
{ {
const NeighborPlugin *plugin = GetNeighborPluginByName(plugin_name); const NeighborPlugin *plugin = GetNeighborPluginByName(plugin_name);
if (plugin == nullptr) if (plugin == nullptr)
throw FmtRuntimeError("No such neighbor plugin: {}", throw FmtRuntimeError("No such neighbor plugin: {:?}",
plugin_name); plugin_name);
return plugin->create(loop, listener, block); return plugin->create(loop, listener, block);
@ -56,7 +56,7 @@ NeighborGlue::Open()
for (auto k = explorers.begin(); k != i; ++k) for (auto k = explorers.begin(); k != i; ++k)
k->explorer->Close(); k->explorer->Close();
std::throw_with_nested(FmtRuntimeError("Failed to open neighblor plugin '{}'", std::throw_with_nested(FmtRuntimeError("Failed to open neighblor plugin {:?}",
i->name)); i->name));
} }
} }

View File

@ -151,7 +151,7 @@ ReadServers(SmbclientContext &ctx, const char *uri,
ReadServers(ctx, handle, list); ReadServers(ctx, handle, list);
ctx.CloseDirectory(handle); ctx.CloseDirectory(handle);
} else } else
FmtError(smbclient_domain, "smbc_opendir('{}') failed: {}", FmtError(smbclient_domain, "smbc_opendir({:?}) failed: {}",
uri, strerror(errno)); uri, strerror(errno));
} }

View File

@ -268,7 +268,7 @@ AudioOutputControl::Open(std::unique_lock<Mutex> &lock,
output->mixer->LockOpen(); output->mixer->LockOpen();
} catch (...) { } catch (...) {
FmtError(output_domain, FmtError(output_domain,
"Failed to open mixer for '{}': {}", "Failed to open mixer for {:?}: {}",
GetName(), std::current_exception()); GetName(), std::current_exception());
} }
} }

View File

@ -56,7 +56,7 @@ audio_output_detect()
continue; continue;
FmtInfo(output_domain, FmtInfo(output_domain,
"Attempting to detect a {} audio device", "Attempting to detect a {:?} audio device",
plugin->name); plugin->name);
if (ao_plugin_test_default_device(plugin)) if (ao_plugin_test_default_device(plugin))
return plugin; return plugin;
@ -154,7 +154,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block,
config_audio_format.Clear(); config_audio_format.Clear();
} }
log_name = fmt::format("\"{}\" ({})", name, plugin_name); log_name = fmt::format("{:?} ({})", name, plugin_name);
/* create the normalization filter (if configured) */ /* create the normalization filter (if configured) */
@ -173,7 +173,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block,
has been set up already and even an empty one will has been set up already and even an empty one will
work (if only with unexpected behaviour) */ work (if only with unexpected behaviour) */
FmtError(output_domain, FmtError(output_domain,
"Failed to initialize filter chain for '{}': {}", "Failed to initialize filter chain for {:?}: {}",
name, std::current_exception()); name, std::current_exception());
} }
} }
@ -223,7 +223,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
mixer_listener); mixer_listener);
} catch (...) { } catch (...) {
FmtError(output_domain, FmtError(output_domain,
"Failed to initialize hardware mixer for '{}': {}", "Failed to initialize hardware mixer for {:?}: {}",
name, std::current_exception()); name, std::current_exception());
} }
@ -235,7 +235,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
mixer, 100); mixer, 100);
else else
FmtError(output_domain, FmtError(output_domain,
"No such mixer for output '{}'", name); "No such mixer for output {:?}", name);
} else if (!StringIsEqual(replay_gain_handler, "software") && } else if (!StringIsEqual(replay_gain_handler, "software") &&
prepared_replay_gain_filter != nullptr) { prepared_replay_gain_filter != nullptr) {
throw std::runtime_error("Invalid \"replay_gain_handler\" value"); throw std::runtime_error("Invalid \"replay_gain_handler\" value");

View File

@ -57,7 +57,7 @@ audio_output_state_read(const char *line, MultipleOutputs &outputs)
auto *ao = outputs.FindByName(name); auto *ao = outputs.FindByName(name);
if (ao == nullptr) { if (ao == nullptr) {
FmtDebug(output_domain, FmtDebug(output_domain,
"Ignoring device state for '{}'", name); "Ignoring device state for {:?}", name);
return true; return true;
} }

View File

@ -792,14 +792,14 @@ AlsaOutput::Open(AudioFormat &audio_format)
SND_PCM_STREAM_PLAYBACK, mode); SND_PCM_STREAM_PLAYBACK, mode);
if (err < 0) if (err < 0)
throw Alsa::MakeError(err, throw Alsa::MakeError(err,
FmtBuffer<256>("Failed to open ALSA device \"{}\"", FmtBuffer<256>("Failed to open ALSA device {:?}",
GetDevice())); GetDevice()));
const char *pcm_name = snd_pcm_name(pcm); const char *pcm_name = snd_pcm_name(pcm);
if (pcm_name == nullptr) if (pcm_name == nullptr)
pcm_name = "?"; pcm_name = "?";
FmtDebug(alsa_output_domain, "opened {} type={}", FmtDebug(alsa_output_domain, "opened {:?} type={}",
pcm_name, pcm_name,
snd_pcm_type_name(snd_pcm_type(pcm))); snd_pcm_type_name(snd_pcm_type(pcm)));
@ -830,7 +830,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
); );
} catch (...) { } catch (...) {
snd_pcm_close(pcm); snd_pcm_close(pcm);
std::throw_with_nested(FmtRuntimeError("Error opening ALSA device \"{}\"", std::throw_with_nested(FmtRuntimeError("Error opening ALSA device {:?}",
GetDevice())); GetDevice()));
} }
@ -891,11 +891,11 @@ AlsaOutput::Recover(int err) noexcept
{ {
if (err == -EPIPE) { if (err == -EPIPE) {
FmtDebug(alsa_output_domain, FmtDebug(alsa_output_domain,
"Underrun on ALSA device \"{}\"", "Underrun on ALSA device {:?}",
GetDevice()); GetDevice());
} else if (err == -ESTRPIPE) { } else if (err == -ESTRPIPE) {
FmtDebug(alsa_output_domain, FmtDebug(alsa_output_domain,
"ALSA device \"{}\" was suspended", "ALSA device {:?} was suspended",
GetDevice()); GetDevice());
} }

View File

@ -105,14 +105,14 @@ AoOutput::AoOutput(const ConfigBlock &block)
driver = ao_driver_id(value); driver = ao_driver_id(value);
if (driver < 0) if (driver < 0)
throw FmtRuntimeError("\"{}\" is not a valid ao driver", throw FmtRuntimeError("{:?} is not a valid ao driver",
value); value);
ao_info *ai = ao_driver_info(driver); ao_info *ai = ao_driver_info(driver);
if (ai == nullptr) if (ai == nullptr)
throw std::runtime_error("problems getting driver info"); throw std::runtime_error("problems getting driver info");
FmtDebug(ao_output_domain, "using ao driver \"{}\" for \"{}\"\n", FmtDebug(ao_output_domain, "using ao driver {:?} for {:?}\n",
ai->short_name, block.GetBlockValue("name", nullptr)); ai->short_name, block.GetBlockValue("name", nullptr));
value = block.GetBlockValue("options", nullptr); value = block.GetBlockValue("options", nullptr);
@ -120,7 +120,7 @@ AoOutput::AoOutput(const ConfigBlock &block)
for (const std::string_view i : IterableSplitString(value, ';')) { for (const std::string_view i : IterableSplitString(value, ';')) {
const auto [n, v] = Split(Strip(i), '='); const auto [n, v] = Split(Strip(i), '=');
if (n.empty() || v.data() == nullptr) if (n.empty() || v.data() == nullptr)
throw FmtRuntimeError("problems parsing option \"{}\"", throw FmtRuntimeError("problems parsing option {:?}",
i); i);
ao_append_option(&options, std::string{n}.c_str(), ao_append_option(&options, std::string{n}.c_str(),

View File

@ -74,7 +74,7 @@ inline void
FifoOutput::Delete() FifoOutput::Delete()
{ {
FmtDebug(fifo_output_domain, FmtDebug(fifo_output_domain,
"Removing FIFO \"{}\"", path); "Removing FIFO {:?}", path);
try { try {
RemoveFile(path); RemoveFile(path);
@ -108,7 +108,7 @@ inline void
FifoOutput::Create() FifoOutput::Create()
{ {
if (!MakeFifo(path, 0666)) if (!MakeFifo(path, 0666))
throw FmtErrno("Couldn't create FIFO \"{}\"", path); throw FmtErrno("Couldn't create FIFO {:?}", path);
created = true; created = true;
} }
@ -124,11 +124,11 @@ FifoOutput::Check()
return; return;
} }
throw FmtErrno("Failed to stat FIFO \"{}\"", path); throw FmtErrno("Failed to stat FIFO {:?}", path);
} }
if (!S_ISFIFO(st.st_mode)) if (!S_ISFIFO(st.st_mode))
throw FmtRuntimeError("\"{}\" already exists, but is not a FIFO", throw FmtRuntimeError("{:?} already exists, but is not a FIFO",
path); path);
} }
@ -139,12 +139,12 @@ try {
input = OpenFile(path, O_RDONLY|O_NONBLOCK|O_BINARY, 0).Steal(); input = OpenFile(path, O_RDONLY|O_NONBLOCK|O_BINARY, 0).Steal();
if (input < 0) if (input < 0)
throw FmtErrno("Could not open FIFO \"{}\" for reading", throw FmtErrno("Could not open FIFO {:?} for reading",
path); path);
output = OpenFile(path, O_WRONLY|O_NONBLOCK|O_BINARY, 0).Steal(); output = OpenFile(path, O_WRONLY|O_NONBLOCK|O_BINARY, 0).Steal();
if (output < 0) if (output < 0)
throw FmtErrno("Could not open FIFO \"{}\" for writing"); throw FmtErrno("Could not open FIFO {:?} for writing");
} catch (...) { } catch (...) {
CloseFifo(); CloseFifo();
throw; throw;
@ -175,7 +175,7 @@ FifoOutput::Cancel() noexcept
if (bytes < 0 && errno != EAGAIN) { if (bytes < 0 && errno != EAGAIN) {
FmtError(fifo_output_domain, FmtError(fifo_output_domain,
"Flush of FIFO \"{}\" failed: {}", "Flush of FIFO {:?} failed: {}",
path, strerror(errno)); path, strerror(errno));
} }
} }

View File

@ -410,7 +410,7 @@ JackOutput::Connect()
portflags, 0); portflags, 0);
if (ports[i] == nullptr) { if (ports[i] == nullptr) {
Disconnect(); Disconnect();
throw FmtRuntimeError("Cannot register output port \"{}\"", throw FmtRuntimeError("Cannot register output port {:?}",
source_ports[i]); source_ports[i]);
} }
} }
@ -521,7 +521,7 @@ JackOutput::Start()
jports[num_dports] != nullptr; jports[num_dports] != nullptr;
++num_dports) { ++num_dports) {
FmtDebug(jack_output_domain, FmtDebug(jack_output_domain,
"destination_port[{}] = '{}'\n", "destination_port[{}] = {:?}\n",
num_dports, jports[num_dports]); num_dports, jports[num_dports]);
dports[num_dports] = jports[num_dports]; dports[num_dports] = jports[num_dports];
} }

View File

@ -260,7 +260,7 @@ osx_output_parse_channel_map(const char *device_name,
continue; continue;
} }
throw FmtRuntimeError("{}: invalid character '{}' in channel map", throw FmtRuntimeError("{}: invalid character {:?} in channel map",
device_name, *channel_map_str); device_name, *channel_map_str);
} }
@ -567,7 +567,7 @@ FindAudioDeviceByName(const char *name)
return id; return id;
} }
throw FmtRuntimeError("Found no audio device names '{}'", name); throw FmtRuntimeError("Found no audio device names {:?}", name);
} }
static void static void

View File

@ -110,13 +110,13 @@ OpenALOutput::SetupContext()
{ {
device = alcOpenDevice(device_name); device = alcOpenDevice(device_name);
if (device == nullptr) if (device == nullptr)
throw FmtRuntimeError("Error opening OpenAL device \"{}\"", throw FmtRuntimeError("Error opening OpenAL device {:?}",
device_name); device_name);
context = alcCreateContext(device, nullptr); context = alcCreateContext(device, nullptr);
if (context == nullptr) { if (context == nullptr) {
alcCloseDevice(device); alcCloseDevice(device);
throw FmtRuntimeError("Error creating context for \"{}\"", throw FmtRuntimeError("Error creating context for {:?}",
device_name); device_name);
} }
} }

View File

@ -166,7 +166,7 @@ oss_output_test_default_device() noexcept
return true; return true;
FmtError(oss_output_domain, FmtError(oss_output_domain,
"Error opening OSS device \"{}\": {}", "Error opening OSS device {:?}: {}",
default_devices[i], strerror(errno)); default_devices[i], strerror(errno));
} }
@ -621,7 +621,7 @@ try {
assert(!fd.IsDefined()); assert(!fd.IsDefined());
if (!fd.Open(device, O_WRONLY)) if (!fd.Open(device, O_WRONLY))
throw FmtErrno("Error opening OSS device \"{}\"", device); throw FmtErrno("Error opening OSS device {:?}", device);
OssIoctlExact(fd, SNDCTL_DSP_CHANNELS, effective_channels, OssIoctlExact(fd, SNDCTL_DSP_CHANNELS, effective_channels,
"Failed to set channel count"); "Failed to set channel count");
@ -638,7 +638,7 @@ void
OssOutput::Open(AudioFormat &_audio_format) OssOutput::Open(AudioFormat &_audio_format)
try { try {
if (!fd.Open(device, O_WRONLY)) if (!fd.Open(device, O_WRONLY))
throw FmtErrno("Error opening OSS device \"{}\"", device); throw FmtErrno("Error opening OSS device {:?}", device);
SetupOrDop(_audio_format); SetupOrDop(_audio_format);
} catch (...) { } catch (...) {
@ -676,7 +676,7 @@ OssOutput::Play(std::span<const std::byte> src)
return pcm_export->CalcInputSize(ret); return pcm_export->CalcInputSize(ret);
if (ret < 0 && errno != EINTR) if (ret < 0 && errno != EINTR)
throw FmtErrno("Write error on {}", device); throw FmtErrno("Write error on {:?}", device);
} }
} }

View File

@ -45,7 +45,7 @@ PipeOutput::Open([[maybe_unused]] AudioFormat &audio_format)
{ {
fh = popen(cmd.c_str(), "w"); fh = popen(cmd.c_str(), "w");
if (fh == nullptr) if (fh == nullptr)
throw FmtErrno("Error opening pipe \"{}\"", cmd); throw FmtErrno("Error opening pipe {:?}", cmd);
} }
std::size_t std::size_t

View File

@ -261,7 +261,7 @@ RecorderOutput::ReopenFormat(AllocatedPath &&new_path)
path = std::move(new_path); path = std::move(new_path);
file = new_file; file = new_file;
FmtDebug(recorder_domain, "Recording to \"{}\"", path); FmtDebug(recorder_domain, "Recording to {:?}", path);
} }
void void

View File

@ -88,7 +88,7 @@ require_block_string(const ConfigBlock &block, const char *name)
{ {
const char *value = block.GetBlockValue(name); const char *value = block.GetBlockValue(name);
if (value == nullptr) if (value == nullptr)
throw FmtRuntimeError("no \"{}\" defined for shout device defined " throw FmtRuntimeError("no {:?} defined for shout device defined "
"at line {}\n", name, block.line); "at line {}\n", name, block.line);
return value; return value;
@ -123,7 +123,7 @@ ParseShoutTls(const char *value)
else if (StringIsEqual(value, "rfc2817")) else if (StringIsEqual(value, "rfc2817"))
return SHOUT_TLS_RFC2817; return SHOUT_TLS_RFC2817;
else else
throw FmtRuntimeError("invalid shout TLS option \"{}\"", throw FmtRuntimeError("invalid shout TLS option {:?}",
value); value);
} }
@ -146,7 +146,7 @@ ParseShoutProtocol(const char *value, const char *mime_type)
if (StringIsEqual(value, "shoutcast")) { if (StringIsEqual(value, "shoutcast")) {
if (!StringIsEqual(mime_type, "audio/mpeg")) if (!StringIsEqual(mime_type, "audio/mpeg"))
throw FmtRuntimeError("you cannot stream \"{}\" to shoutcast, use mp3", throw FmtRuntimeError("you cannot stream {:?} to shoutcast, use mp3",
mime_type); mime_type);
return SHOUT_PROTOCOL_ICY; return SHOUT_PROTOCOL_ICY;
} else if (StringIsEqual(value, "icecast1")) } else if (StringIsEqual(value, "icecast1"))
@ -154,7 +154,7 @@ ParseShoutProtocol(const char *value, const char *mime_type)
else if (StringIsEqual(value, "icecast2")) else if (StringIsEqual(value, "icecast2"))
return SHOUT_PROTOCOL_HTTP; return SHOUT_PROTOCOL_HTTP;
else else
throw FmtRuntimeError("shout protocol \"{}\" is not \"shoutcast\" or " throw FmtRuntimeError("shout protocol {:?} is not \"shoutcast\" or "
"\"icecast1\"or \"icecast2\"", "\"icecast1\"or \"icecast2\"",
value); value);
} }

View File

@ -106,7 +106,7 @@ get_device_id(const char *device_name)
UINT id = strtoul(device_name, &endptr, 0); UINT id = strtoul(device_name, &endptr, 0);
if (endptr > device_name && *endptr == 0) { if (endptr > device_name && *endptr == 0) {
if (id >= numdevs) if (id >= numdevs)
throw FmtRuntimeError("device \"{}\" is not found", throw FmtRuntimeError("device {:?} is not found",
device_name); device_name);
return id; return id;
@ -127,7 +127,7 @@ get_device_id(const char *device_name)
return i; return i;
} }
throw FmtRuntimeError("device \"{}\" is not found", device_name); throw FmtRuntimeError("device {:?} is not found", device_name);
} }
WinmmOutput::WinmmOutput(const ConfigBlock &block) WinmmOutput::WinmmOutput(const ConfigBlock &block)

View File

@ -789,7 +789,7 @@ WasapiOutput::ChooseDevice()
if (!SafeSilenceTry([this, &id]() { id = std::stoul(device_config); })) { if (!SafeSilenceTry([this, &id]() { id = std::stoul(device_config); })) {
device = SearchDevice(*enumerator, device_config); device = SearchDevice(*enumerator, device_config);
if (!device) if (!device)
throw FmtRuntimeError("Device '{}' not found", throw FmtRuntimeError("Device {:?} not found",
device_config); device_config);
} else } else
device = GetDevice(*enumerator, id); device = GetDevice(*enumerator, id);
@ -1007,7 +1007,7 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator)
continue; continue;
FmtNotice(wasapi_output_domain, FmtNotice(wasapi_output_domain,
"Device \"{}\" \"{}\"", i, name.c_str()); "Device {:?} {:?}", i, name.c_str());
} }
} }

View File

@ -53,11 +53,11 @@ pcm_resample_lsr_global_init(const ConfigBlock &block)
{ {
const char *converter = block.GetBlockValue("type", "2"); const char *converter = block.GetBlockValue("type", "2");
if (!lsr_parse_converter(converter)) if (!lsr_parse_converter(converter))
throw FmtRuntimeError("unknown samplerate converter '{}'", throw FmtRuntimeError("unknown samplerate converter {:?}",
converter); converter);
FmtDebug(libsamplerate_domain, FmtDebug(libsamplerate_domain,
"libsamplerate converter '{}'", "libsamplerate converter {:?}",
src_get_name(lsr_converter)); src_get_name(lsr_converter));
} }

View File

@ -153,7 +153,7 @@ pcm_resample_soxr_global_init(const ConfigBlock &block)
if (recipe == SOXR_INVALID_RECIPE) { if (recipe == SOXR_INVALID_RECIPE) {
assert(quality_string != nullptr); assert(quality_string != nullptr);
throw FmtRuntimeError("unknown quality setting '{}' in line {}", throw FmtRuntimeError("unknown quality setting {:?} in line {}",
quality_string, block.line); quality_string, block.line);
} else if (recipe == SOXR_CUSTOM_RECIPE) { } else if (recipe == SOXR_CUSTOM_RECIPE) {
// used to preset possible internal flags, like SOXR_RESET_ON_CLEAR // used to preset possible internal flags, like SOXR_RESET_ON_CLEAR
@ -177,7 +177,7 @@ pcm_resample_soxr_global_init(const ConfigBlock &block)
soxr_quality = soxr_quality_spec(recipe, 0); soxr_quality = soxr_quality_spec(recipe, 0);
} }
FmtDebug(soxr_domain, "soxr converter '{}'", FmtDebug(soxr_domain, "soxr converter {:?}",
soxr_quality_name(recipe)); soxr_quality_name(recipe));
const unsigned n_threads = block.GetBlockValue("threads", 1); const unsigned n_threads = block.GetBlockValue("threads", 1);
@ -202,7 +202,7 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
throw FmtRuntimeError("soxr initialization has failed: {}", throw FmtRuntimeError("soxr initialization has failed: {}",
e); e);
FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr)); FmtDebug(soxr_domain, "soxr engine {:?}", soxr_engine(soxr));
if (soxr_use_custom_recipe) if (soxr_use_custom_recipe)
FmtDebug(soxr_domain, FmtDebug(soxr_domain,
"soxr precision={:0.0f}, phase_response={:0.2f}, " "soxr precision={:0.0f}, phase_response={:0.2f}, "

View File

@ -623,7 +623,7 @@ Player::CheckDecoderStartup(std::unique_lock<Mutex> &lock) noexcept
if (!paused && !OpenOutput()) { if (!paused && !OpenOutput()) {
FmtError(player_domain, FmtError(player_domain,
"problems opening audio device " "problems opening audio device "
"while playing \"{}\"", "while playing {:?}",
dc.song->GetURI()); dc.song->GetURI());
return true; return true;
} }
@ -1065,7 +1065,7 @@ Player::SongBorder() noexcept
{ {
const ScopeUnlock unlock(pc.mutex); const ScopeUnlock unlock(pc.mutex);
FmtNotice(player_domain, "played \"{}\"", song->GetURI()); FmtNotice(player_domain, "played {:?}", song->GetURI());
ReplacePipe(dc.pipe); ReplacePipe(dc.pipe);
@ -1211,7 +1211,7 @@ Player::Run() noexcept
cross_fade_tag.reset(); cross_fade_tag.reset();
if (song != nullptr) { if (song != nullptr) {
FmtNotice(player_domain, "played \"{}\"", song->GetURI()); FmtNotice(player_domain, "played {:?}", song->GetURI());
song.reset(); song.reset();
} }

View File

@ -45,7 +45,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
loader)) { loader)) {
failures += 1; failures += 1;
if (failures < max_log_msgs) { if (failures < max_log_msgs) {
FmtError(playlist_domain, "Failed to load \"{}\".", song->GetURI()); FmtError(playlist_domain, "Failed to load {:?}.", song->GetURI());
} else if (failures == max_log_msgs) { } else if (failures == max_log_msgs) {
LogError(playlist_domain, "Further errors for this playlist will not be logged."); LogError(playlist_domain, "Further errors for this playlist will not be logged.");
} }

View File

@ -56,7 +56,7 @@ playlist::QueueSongOrder(PlayerControl &pc, unsigned order) noexcept
const DetachedSong &song = queue.GetOrder(order); const DetachedSong &song = queue.GetOrder(order);
FmtDebug(playlist_domain, "queue song {}:\"{}\"", FmtDebug(playlist_domain, "queue song {}:{:?}",
queued, song.GetURI()); queued, song.GetURI());
pc.LockEnqueueSong(std::make_unique<DetachedSong>(song)); pc.LockEnqueueSong(std::make_unique<DetachedSong>(song));
@ -168,7 +168,7 @@ playlist::PlayOrder(PlayerControl &pc, unsigned order)
const DetachedSong &song = queue.GetOrder(order); const DetachedSong &song = queue.GetOrder(order);
FmtDebug(playlist_domain, "play {}:\"{}\"", order, song.GetURI()); FmtDebug(playlist_domain, "play {}:{:?}", order, song.GetURI());
current = order; current = order;

View File

@ -76,7 +76,7 @@ public:
UnmountWait(); UnmountWait();
} catch (...) { } catch (...) {
FmtError(udisks_domain, FmtError(udisks_domain,
"Failed to unmount '{}': {}", "Failed to unmount {:?}: {}",
base_uri, std::current_exception()); base_uri, std::current_exception());
} }
} }

View File

@ -44,7 +44,7 @@ TagLoadConfig(const ConfigData &config)
const auto type = tag_name_parse_i(name); const auto type = tag_name_parse_i(name);
if (type == TAG_NUM_OF_ITEM_TYPES) if (type == TAG_NUM_OF_ITEM_TYPES)
throw FmtRuntimeError("error parsing metadata item \"{}\"", throw FmtRuntimeError("error parsing metadata item {:?}",
name); name);
if (plus) if (plus)

View File

@ -56,7 +56,7 @@ daemonize_kill()
const pid_t pid = ReadPidFile(pidfile); const pid_t pid = ReadPidFile(pidfile);
if (pid < 0) if (pid < 0)
throw FmtErrno("unable to read the pid from file \"{}\"", throw FmtErrno("unable to read the pid from file {:?}",
pidfile); pidfile);
if (kill(pid, SIGTERM) < 0) if (kill(pid, SIGTERM) < 0)
@ -94,7 +94,7 @@ daemonize_set_user()
user_uid != getuid() && user_uid != getuid() &&
initgroups(user_name, user_gid) == -1) { initgroups(user_name, user_gid) == -1) {
throw FmtErrno("Failed to set supplementary groups " throw FmtErrno("Failed to set supplementary groups "
"of user \"{}\"", "of user {:?}",
user_name); user_name);
} }
#endif #endif
@ -102,7 +102,7 @@ daemonize_set_user()
/* set uid */ /* set uid */
if (user_uid != (uid_t)-1 && user_uid != getuid() && if (user_uid != (uid_t)-1 && user_uid != getuid() &&
setuid(user_uid) == -1) { setuid(user_uid) == -1) {
throw FmtErrno("Failed to set user \"{}\"", user_name); throw FmtErrno("Failed to set user {:?}", user_name);
} }
} }
@ -201,7 +201,7 @@ daemonize_init(const char *user, const char *group, AllocatedPath &&_pidfile)
if (user) { if (user) {
struct passwd *pwd = getpwnam(user); struct passwd *pwd = getpwnam(user);
if (pwd == nullptr) if (pwd == nullptr)
throw FmtRuntimeError("no such user \"{}\"", user); throw FmtRuntimeError("no such user {:?}", user);
user_uid = pwd->pw_uid; user_uid = pwd->pw_uid;
user_gid = pwd->pw_gid; user_gid = pwd->pw_gid;
@ -215,7 +215,7 @@ daemonize_init(const char *user, const char *group, AllocatedPath &&_pidfile)
if (group) { if (group) {
struct group *grp = getgrnam(group); struct group *grp = getgrnam(group);
if (grp == nullptr) if (grp == nullptr)
throw FmtRuntimeError("no such group \"{}\"", group); throw FmtRuntimeError("no such group {:?}", group);
user_gid = grp->gr_gid; user_gid = grp->gr_gid;
had_group = true; had_group = true;
} }

View File

@ -27,7 +27,7 @@ public:
fd = OpenFile(path, O_WRONLY|O_CREAT|O_TRUNC, 0666).Steal(); fd = OpenFile(path, O_WRONLY|O_CREAT|O_TRUNC, 0666).Steal();
if (fd < 0) if (fd < 0)
throw FmtErrno("Failed to create pid file \"{}\"", throw FmtErrno("Failed to create pid file {:?}",
path); path);
} }

View File

@ -63,7 +63,7 @@ BonjourHelper::Callback([[maybe_unused]] DNSServiceRef sdRef,
helper.Cancel(); helper.Cancel();
} else { } else {
FmtDebug(bonjour_domain, FmtDebug(bonjour_domain,
"Registered zeroconf service with name '{}'", "Registered zeroconf service with name {:?}",
name); name);
} }
} }

View File

@ -47,7 +47,7 @@ AvahiInit(EventLoop &event_loop, const char *service_name,
const char *service_type, unsigned port) const char *service_type, unsigned port)
{ {
if (!avahi_is_valid_service_name(service_name)) if (!avahi_is_valid_service_name(service_name))
throw FmtRuntimeError("Invalid zeroconf_name \"{}\"", throw FmtRuntimeError("Invalid zeroconf_name {:?}",
service_name); service_name);
auto client = shared_avahi_client.lock(); auto client = shared_avahi_client.lock();

View File

@ -55,7 +55,7 @@ public:
} }
void OnDatabaseSongRemoved(const char *uri) noexcept override { void OnDatabaseSongRemoved(const char *uri) noexcept override {
fmt::print("SongRemoved '{}'\n", uri); fmt::print("SongRemoved {:?}\n", uri);
} }
}; };