00001 /* 00002 * Base exceptions header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_BASE_EXCEPTIONS_H__ 00009 #define __SP_BASE_EXCEPTIONS_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 #include "Base/spInputOutputString.hpp" 00014 00015 00016 namespace sp 00017 { 00018 namespace io 00019 { 00020 00021 00023 class SP_EXPORT DefaultException : public std::exception 00024 { 00025 00026 public: 00027 00028 DefaultException(const io::stringc &Message) throw() : 00029 Message_(Message) 00030 { 00031 } 00032 ~DefaultException() throw() 00033 { 00034 } 00035 00036 const c8* what() const throw() 00037 { 00038 return Message_.c_str(); 00039 } 00040 00041 private: 00042 00043 io::stringc Message_; 00044 00045 }; 00046 00047 00049 class SP_EXPORT RenderSystemException : public std::exception 00050 { 00051 00052 public: 00053 00054 RenderSystemException(const io::stringc &ObjectName) throw() : 00055 ObjectName_(ObjectName) 00056 { 00057 } 00058 ~RenderSystemException() throw() 00059 { 00060 } 00061 00062 const c8* what() const throw() 00063 { 00064 return ("\"" + ObjectName_ + "\" has been instantiated before global render system has been created").c_str(); 00065 } 00066 00067 private: 00068 00069 io::stringc ObjectName_; 00070 00071 }; 00072 00073 00075 class SP_EXPORT NullPointerException : public std::exception 00076 { 00077 00078 public: 00079 00080 NullPointerException(const io::stringc &Origin) throw() : 00081 Origin_(Origin) 00082 { 00083 } 00084 ~NullPointerException() throw() 00085 { 00086 } 00087 00088 const c8* what() const throw() 00089 { 00090 return ("Null pointer has been passed to \"" + Origin_ + "\" where it is not allowed").c_str(); 00091 } 00092 00093 private: 00094 00095 io::stringc Origin_; 00096 00097 }; 00098 00099 00100 } // /namespace io 00101 00102 } // /namespace sp 00103 00104 00105 #endif 00106 00107 00108 00109 // ================================================================================