00001 // exception.h -*-c++-*- 00002 // 00003 // Copyright (C) 2005, 2007 Daniel Burrows 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License as 00007 // published by the Free Software Foundation; either version 2 of 00008 // the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; see the file COPYING. If not, write to 00017 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 // Boston, MA 02111-1307, USA. 00019 // 00020 // A generic exception class supporting std::string error messages 00021 // (unlike std::exception, which only supports const char* error 00022 // messages). If execinfo is available and ENABLE_DYNAMIC_BACKTRACE 00023 // is defined, it also generates information about the state of the 00024 // stack at the time of its instantiation (if not, then 00025 // get_backtrace() returns an empty string). 00026 00027 #ifndef EXCEPTION_H 00028 #define EXCEPTION_H 00029 00030 #include <string> 00031 #include <vector> 00032 00033 namespace cwidget 00034 { 00035 namespace util 00036 { 00037 class Exception 00038 { 00042 std::string bt; 00043 public: 00044 Exception(); 00045 00046 std::string get_backtrace() const { return bt; } 00047 virtual std::string errmsg() const = 0; 00048 virtual ~Exception() {} 00049 }; 00050 } 00051 } 00052 00053 #endif