]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/except.cpp
Rename error.* to except.*
[libs/core.git] / source / core / except.cpp
diff --git a/source/core/except.cpp b/source/core/except.cpp
new file mode 100644 (file)
index 0000000..245bc05
--- /dev/null
@@ -0,0 +1,39 @@
+/* $Id$
+
+This file is part of libmspcore
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+#include <sstream>
+#include "except.h"
+
+using namespace std;
+
+namespace Msp {
+
+Exception::Exception(const string &w_):
+       w(w_)
+{
+#ifdef WITH_EXCEPTION_BACKTRACE
+       bt=Debug::Backtrace::create();
+#endif
+}
+
+SystemError::SystemError(const string &w_, int e):
+       Exception(build_what(w_, e)),
+       err(e)
+{ }
+
+string SystemError::build_what(const string &w, int e)
+{
+       ostringstream buf;
+       buf<<w<<": ";
+#ifdef WIN32
+       buf<<e;
+#else
+       buf<<strerror(e);
+#endif
+       return buf.str();
+}
+
+} // namespace Msp