]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/except.cpp
Remove an obsolete Makefile
[libs/core.git] / source / core / except.cpp
index 245bc0502c0481b36a218531bb14bff93c2fbc13..ddd2cb5167d57f0e3f5df614a8caf3ad3b68dc50 100644 (file)
@@ -4,7 +4,12 @@ This file is part of libmspcore
 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
+
 #include <sstream>
+#include <cstring>
+#ifdef WIN32
+#include <windows.h>
+#endif
 #include "except.h"
 
 using namespace std;
@@ -24,12 +29,21 @@ SystemError::SystemError(const string &w_, int e):
        err(e)
 { }
 
+KeyError::KeyError(const string &w_, const string &k):
+       Exception(w_+" ("+k+")"),
+       key(k)
+{ }
+
 string SystemError::build_what(const string &w, int e)
 {
        ostringstream buf;
        buf<<w<<": ";
 #ifdef WIN32
-       buf<<e;
+       char msg[1024];
+       if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, e, 0, msg, sizeof(msg), 0))
+               buf<<msg;
+       else
+               buf<<e;
 #else
        buf<<strerror(e);
 #endif