KatanaNativeInterface $VERSION$
exception.h
Go to the documentation of this file.
1//
2// C++ Interface: exception
3//
4// Description:
5//
6//
7// Author: Tiziano Müller <tiziano.mueller@neuronics.ch>, (C) 2006
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12
13#ifndef _EXCEPTION_H_
14#define _EXCEPTION_H_
15
16
17#include <string>
18#include "dllexport.h"
19
20
21#ifdef HAVE_LIBEBT
22
23#include <libebt/libebt.hh>
24#include <libebt/libebt_util.hh>
25
26struct ExceptionTag { };
27typedef libebt::BacktraceContext<ExceptionTag, std::string> Context;
28
29
34
35class DLLDIR Exception : public libebt::Backtraceable<ExceptionTag>,
36 public std::exception {
37 protected:
38 const std::string _message;
39 const int _error_number;
40
41 public:
42 Exception(const std::string & message, const int error_number) throw () :
43 libebt::Backtraceable<ExceptionTag>(),
44 std::exception(),
45 _message(message), _error_number(error_number) {
46 }
47
48 virtual ~Exception() throw () {
49 }
50
51 std::string message() const throw() {
52 return _message;
53 }
54 const char* what() const throw() {
55 return _message.c_str();
56 }
57
58 const int error_number() const throw() {
59 return _error_number;
60 }
61};
62
66
67#else // HAVE_LIBEBT
68
73
74// The compiler should optimize that away
76 Context(const char*) {}
77};
78
79class DLLDIR Exception : public std::exception {
80 protected:
81 const std::string _message;
82 const int _error_number;
83
84 public:
85 Exception(const std::string & message, const int error_number) throw () :
86 std::exception(),
87 _message(message), _error_number(error_number) {
88 }
89
90 virtual ~Exception() throw () {
91 }
92
93 std::string message() const throw() {
94 return _message;
95 }
96 const char* what() const throw() {
97 return _message.c_str();
98 }
99
100 const int error_number() const throw() {
101 return _error_number;
102 }
103};
104
108
109
110#endif
111
112#endif
Exception(const std::string &message, const int error_number)
Definition: exception.h:85
const std::string _message
Definition: exception.h:81
const int error_number() const
Definition: exception.h:100
const char * what() const
Definition: exception.h:96
const int _error_number
Definition: exception.h:82
std::string message() const
Definition: exception.h:93
virtual ~Exception()
Definition: exception.h:90
#define DLLDIR
Definition: dllexport.h:30
Context(const char *)
Definition: exception.h:76