libopenraw
|
00001 /* 00002 * libopenraw - exception.h 00003 * 00004 * Copyright (C) 2006-2007 Hubert Figuiere 00005 * 00006 * This library is free software: you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation, either version 3 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library. If not, see 00018 * <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 00022 00023 #ifndef _OPENRAW_EXCEPTION_H_ 00024 #define _OPENRAW_EXCEPTION_H_ 00025 00026 #include <exception> 00027 #include <string> 00028 #include <typeinfo> 00029 00030 namespace OpenRaw { 00031 namespace Internals { 00032 00034 class Exception 00035 : public std::exception 00036 { 00037 protected: 00038 std::string m_what; 00039 public: 00040 Exception() 00041 : std::exception(), 00042 m_what() 00043 {} 00044 Exception(const std::string &w) 00045 : std::exception(), 00046 m_what(w) 00047 {} 00048 virtual ~Exception() throw() 00049 {} 00050 const char *what() const throw() 00051 { 00052 if(m_what.empty()) { 00053 return typeid(this).name(); 00054 } 00055 return m_what.c_str(); 00056 } 00057 }; 00058 00060 class IOException 00061 : public Exception 00062 { 00063 public: 00064 IOException(const std::string &w) 00065 : Exception(w) 00066 {} 00067 }; 00068 00069 00071 class BadTypeException 00072 : public Exception 00073 { 00074 00075 }; 00076 00078 class TooBigException 00079 : public Exception 00080 { 00081 }; 00082 00083 class OutOfRangeException 00084 : public Exception 00085 { 00086 }; 00087 00088 class DecodingException 00089 : public Exception 00090 { 00091 public: 00092 DecodingException(const std::string &w) 00093 : Exception(w) 00094 {} 00095 }; 00096 00097 } 00098 } 00099 00100 #endif