]> git.tdb.fi Git - libs/core.git/blob - source/core/error.cpp
Use dladdr instead of backtrace_symbols in Backtrace::create (both are GNU-specific...
[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 "error.h"
9
10 using namespace std;
11
12 namespace Msp {
13
14 Exception::Exception(const string &w_):
15         w(w_)
16 {
17 #ifdef WITH_EXCEPTION_BACKTRACE
18         bt=Debug::Backtrace::create();
19 #endif
20 }
21
22 SystemError::SystemError(const string &w_, int e):
23         Exception(build_what(w_, e)),
24         err(e)
25 { }
26
27 string SystemError::build_what(const string &w, int e)
28 {
29         ostringstream buf;
30         buf<<w<<": ";
31 #ifdef WIN32
32         buf<<e;
33 #else
34         buf<<strerror(e);
35 #endif
36         return buf.str();
37 }
38
39 } // namespace Msp