exception.h
Go to the documentation of this file.
00001 //
00002 // C++ Interface: exception
00003 //
00004 // Description: 
00005 //
00006 //
00007 // Author: Tiziano Müller <tiziano.mueller@neuronics.ch>, (C) 2006
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 
00013 #ifndef _EXCEPTION_H_
00014 #define _EXCEPTION_H_
00015 
00016 
00017 #include <string>
00018 #include "dllexport.h"
00019 
00020 
00021 #ifdef HAVE_LIBEBT
00022 
00023 #include <libebt/libebt.hh>
00024 #include <libebt/libebt_util.hh>
00025 
00026 struct ExceptionTag { };
00027 typedef libebt::BacktraceContext<ExceptionTag, std::string> Context;
00028 
00029 
00034 
00035 class DLLDIR Exception : public libebt::Backtraceable<ExceptionTag>,
00036                                                  public std::exception {
00037     protected:
00038         const std::string _message;
00039                 const int _error_number;
00040 
00041     public:
00042         Exception(const std::string & message, const int error_number) throw () :
00043             libebt::Backtraceable<ExceptionTag>(),
00044             std::exception(),
00045             _message(message), _error_number(error_number) {
00046         }
00047 
00048         virtual ~Exception() throw () {
00049         }
00050 
00051         std::string message() const throw() {
00052             return _message;
00053         }
00054         const char* what() const throw() {
00055             return _message.c_str();
00056         }
00057 
00058         const int error_number() const throw() {
00059             return _error_number;
00060         }
00061 };
00062 
00066 
00067 #else // HAVE_LIBEBT
00068 
00073 
00074 // The compiler should optimize that away
00075 struct DLLDIR Context {
00076     Context(const char*) {}
00077 };
00078 
00079 class DLLDIR Exception : public std::exception {
00080     protected:
00081         const std::string _message;
00082         const int _error_number;
00083 
00084     public:
00085         Exception(const std::string & message, const int error_number) throw () :
00086             std::exception(),
00087             _message(message), _error_number(error_number) {
00088         }
00089 
00090         virtual ~Exception() throw () {
00091         }
00092 
00093         std::string message() const throw() {
00094             return _message;
00095         }
00096         const char* what() const throw() {
00097             return _message.c_str();
00098         }
00099 
00100         int error_number() const throw() {
00101             return _error_number;
00102         }
00103 };
00104 
00108 
00109 
00110 #endif
00111 
00112 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


kni
Author(s): Neuronics AG (see AUTHORS.txt); ROS wrapper by Martin Günther
autogenerated on Tue May 28 2013 14:52:53