From 1e4bf90c604e76eb7fd3c26a610c7e0f30b09850 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 5 Apr 2024 14:21:24 +0200 Subject: [PATCH] io, net, evnet: quote file names in error messages --- src/event/InotifyEvent.cxx | 2 +- src/io/Open.cxx | 16 ++++++++-------- src/net/Resolver.cxx | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/event/InotifyEvent.cxx b/src/event/InotifyEvent.cxx index 80db3577b..e8f92533d 100644 --- a/src/event/InotifyEvent.cxx +++ b/src/event/InotifyEvent.cxx @@ -46,7 +46,7 @@ InotifyEvent::AddWatch(const char *pathname, uint32_t mask) { int wd = TryAddWatch(pathname, mask); if (wd < 0) - throw FmtErrno("inotify_add_watch('{}') failed", pathname); + throw FmtErrno("inotify_add_watch({:?}) failed", pathname); return wd; } diff --git a/src/io/Open.cxx b/src/io/Open.cxx index 843ad101d..8514e95cb 100644 --- a/src/io/Open.cxx +++ b/src/io/Open.cxx @@ -12,7 +12,7 @@ OpenReadOnly(const char *path, int flags) { UniqueFileDescriptor fd; if (!fd.Open(path, O_RDONLY|flags)) - throw FmtErrno("Failed to open '{}'", path); + throw FmtErrno("Failed to open {:?}", path); return fd; } @@ -22,7 +22,7 @@ OpenWriteOnly(const char *path, int flags) { UniqueFileDescriptor fd; if (!fd.Open(path, O_WRONLY|flags)) - throw FmtErrno("Failed to open '{}'", path); + throw FmtErrno("Failed to open {:?}", path); return fd; } @@ -34,7 +34,7 @@ OpenDirectory(const char *path, int flags) { UniqueFileDescriptor fd; if (!fd.Open(path, O_DIRECTORY|O_RDONLY|flags)) - throw FmtErrno("Failed to open '{}'", path); + throw FmtErrno("Failed to open {:?}", path); return fd; } @@ -48,7 +48,7 @@ OpenPath(const char *path, int flags) { UniqueFileDescriptor fd; if (!fd.Open(path, O_PATH|flags)) - throw FmtErrno("Failed to open '{}'", path); + throw FmtErrno("Failed to open {:?}", path); return fd; } @@ -58,7 +58,7 @@ OpenPath(FileDescriptor directory, const char *name, int flags) { UniqueFileDescriptor fd; if (!fd.Open(directory, name, O_PATH|flags)) - throw FmtErrno("Failed to open '{}'", name); + throw FmtErrno("Failed to open {:?}", name); return fd; } @@ -68,7 +68,7 @@ OpenReadOnly(FileDescriptor directory, const char *name, int flags) { UniqueFileDescriptor fd; if (!fd.Open(directory, name, O_RDONLY|flags)) - throw FmtErrno("Failed to open '{}'", name); + throw FmtErrno("Failed to open {:?}", name); return fd; } @@ -78,7 +78,7 @@ OpenWriteOnly(FileDescriptor directory, const char *name, int flags) { UniqueFileDescriptor fd; if (!fd.Open(directory, name, O_WRONLY|flags)) - throw FmtErrno("Failed to open '{}'", name); + throw FmtErrno("Failed to open {:?}", name); return fd; } @@ -88,7 +88,7 @@ OpenDirectory(FileDescriptor directory, const char *name, int flags) { UniqueFileDescriptor fd; if (!fd.Open(directory, name, O_DIRECTORY|O_RDONLY|flags)) - throw FmtErrno("Failed to open '{}'", name); + throw FmtErrno("Failed to open {:?}", name); return fd; } diff --git a/src/net/Resolver.cxx b/src/net/Resolver.cxx index b01b87b6e..1d9d9a6bf 100644 --- a/src/net/Resolver.cxx +++ b/src/net/Resolver.cxx @@ -32,7 +32,7 @@ Resolve(const char *node, const char *service, #else const char *msg = gai_strerror(error); #endif - throw FmtRuntimeError("Failed to resolve '{}':'{}': {}", + throw FmtRuntimeError("Failed to resolve {:?}:{:?}: {}", node == nullptr ? "" : node, service == nullptr ? "" : service, msg);