/* $Id$
This file is part of libmspcore
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
namespace Msp {
-Exception::Exception(const string &w_):
- w(w_)
+Exception::Exception(const string &w):
+ wot(w)
{
#ifdef WITH_EXCEPTION_BACKTRACE
- bt=Debug::Backtrace::create();
+ bt = Debug::Backtrace::create();
#endif
}
+Exception &Exception::at(const std::string &w) throw()
+{
+ wer = w;
+ wot = wer+": "+wot;
+ return *this;
+}
+
+
SystemError::SystemError(const string &w_, int e):
Exception(build_what(w_, 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
char msg[1024];
- if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, e, 0, msg, sizeof(msg), 0))
+ if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, e, 0, msg, sizeof(msg), 0))
buf<<msg;
else
buf<<e;
return buf.str();
}
+
+KeyError::KeyError(const string &w_, const string &k):
+ Exception(w_+" ("+k+")"),
+ key(k)
+{ }
+
} // namespace Msp