]> git.tdb.fi Git - libs/core.git/blob - source/core/error.cpp
Assimilate exceptions and RefPtr from mspmisc
[libs/core.git] / source / core / error.cpp
1 /* $Id$
2
3 This file is part of libmspcore
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7 #include <sstream>
8 #include "backtrace.h"
9 #include "error.h"
10
11 using namespace std;
12
13 namespace Msp {
14
15 Exception::Exception(const string &w_):
16         w(w_)
17 {
18 #ifdef WITH_EXCEPTION_BACKTRACE
19         bt=Backtrace::create();
20 #endif
21 }
22
23 SystemError::SystemError(const string &w_, int e):
24         Exception(build_what(w_, e)),
25         err(e)
26 { }
27
28 string SystemError::build_what(const string &w, int e)
29 {
30         ostringstream buf;
31         buf<<w<<": ";
32 #ifdef WIN32
33         buf<<e;
34 #else
35         buf<<strerror(e);
36 #endif
37         return buf.str();
38 }
39
40 } // namespace Msp