aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/Error.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-30 21:58:37 +0200
committerMax Kellermann <max@duempel.org>2014-07-30 22:10:31 +0200
commitc8858f85d8366e36c588b1dcc7ef7eff40832dd0 (patch)
tree4a5a8bd89493537f3a7f92dfddac879f3f0bd01c /src/util/Error.cxx
parentd1bc46ffad08e070e24f775dd3e13201d97aeb5d (diff)
downloadmpd-c8858f85d8366e36c588b1dcc7ef7eff40832dd0.tar.gz
mpd-c8858f85d8366e36c588b1dcc7ef7eff40832dd0.tar.xz
mpd-c8858f85d8366e36c588b1dcc7ef7eff40832dd0.zip
util/Error: add method FormatLastError()
Diffstat (limited to 'src/util/Error.cxx')
-rw-r--r--src/util/Error.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util/Error.cxx b/src/util/Error.cxx
index ef8282329..92b2cc5d0 100644
--- a/src/util/Error.cxx
+++ b/src/util/Error.cxx
@@ -145,4 +145,30 @@ Error::SetLastError(const char *prefix)
SetLastError(GetLastError(), prefix);
}
+void
+Error::FormatLastError(DWORD _code, const char *fmt, ...)
+{
+ char buffer[1024];
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(buffer, sizeof(buffer), fmt, ap);
+ va_end(ap);
+
+ SetLastError(_code, buffer);
+}
+
+void
+Error::FormatLastError(const char *fmt, ...)
+{
+ DWORD _code = GetLastError();
+
+ char buffer[1024];
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(buffer, sizeof(buffer), fmt, ap);
+ va_end(ap);
+
+ SetLastError(_code, buffer);
+}
+
#endif