aboutsummaryrefslogtreecommitdiffstats
path: root/src/system/FatalError.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-12-05 00:16:24 +0100
committerMax Kellermann <max@duempel.org>2014-12-05 00:19:07 +0100
commit08bf4f74a99cb542a20e18b896b8565f6bf1f37a (patch)
tree1bb456a97ed3898eac726270ca9685a4640e1266 /src/system/FatalError.cxx
parenta838a03412b7d77cc953c2ec617aa09510f91de8 (diff)
downloadmpd-08bf4f74a99cb542a20e18b896b8565f6bf1f37a.tar.gz
mpd-08bf4f74a99cb542a20e18b896b8565f6bf1f37a.tar.xz
mpd-08bf4f74a99cb542a20e18b896b8565f6bf1f37a.zip
system/FatalError: add FatalSystemError() overload with WIN32 error code
Diffstat (limited to 'src/system/FatalError.cxx')
-rw-r--r--src/system/FatalError.cxx28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/system/FatalError.cxx b/src/system/FatalError.cxx
index a2d06bcb1..cb5d7160a 100644
--- a/src/system/FatalError.cxx
+++ b/src/system/FatalError.cxx
@@ -74,23 +74,31 @@ FatalError(const char *msg, const Error &error)
FormatFatalError("%s: %s", msg, error.GetMessage());
}
+#ifdef WIN32
+
+void
+FatalSystemError(const char *msg, DWORD code)
+{
+ char buffer[256];
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ nullptr, code, 0,
+ buffer, sizeof(buffer), nullptr);
+ FormatFatalError("%s: %s", msg, buffer);
+}
+
+#endif
+
void
FatalSystemError(const char *msg)
{
- const char *system_error;
#ifdef WIN32
- char buffer[256];
- FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- nullptr, GetLastError(), 0,
- buffer, sizeof(buffer), nullptr);
- system_error = buffer;
+ FatalSystemError(msg, GetLastError());
#else
- system_error = strerror(errno);
-#endif
-
+ const char *system_error = strerror(errno);
FormatError(fatal_error_domain, "%s: %s", msg, system_error);
Abort();
+#endif
}
void