00001 #if !defined( __ARSEXCEPTION_H__ ) 00002 #define __ARSEXCEPTION_H__ 00003 00004 namespace Ars 00005 { 00007 class ExceptionBase : public std::exception 00008 { 00009 public: 00011 ExceptionBase(const std::string& sWhat) : m_sWhat(sWhat) { } 00012 00014 virtual ~ExceptionBase(void) throw() { } 00015 00017 virtual const char* what() const throw() { return m_sWhat.c_str(); } 00018 00020 virtual const std::string& std_what() const throw() { return m_sWhat; } 00021 00022 protected: 00023 std::string m_sWhat; 00024 }; 00025 00026 00028 class ExceptionSDL : public ExceptionBase 00029 { 00030 public: 00032 ExceptionSDL(const std::string& sWhat) : ExceptionBase(sWhat) { } 00033 }; 00034 00035 00037 class ExceptionFreeType : public ExceptionBase 00038 { 00039 public: 00041 ExceptionFreeType(const std::string& sWhat) : ExceptionBase(sWhat) { } 00042 }; 00043 00044 00046 class ExceptionApp : public ExceptionBase 00047 { 00048 public: 00050 ExceptionApp(const std::string& sWhat) : ExceptionBase(sWhat) { } 00051 }; 00052 00053 00055 class ExceptionRange : public ExceptionBase 00056 { 00057 public: 00059 ExceptionRange(const std::string& sWhat) : ExceptionBase(sWhat) { } 00060 }; 00061 00063 class ExceptionLexer : public ExceptionBase 00064 { 00065 public: 00067 ExceptionLexer( const std::string& sWhat , const int aLineno ) 00068 : ExceptionBase(sWhat) 00069 { 00070 char tmp[512]; 00071 sprintf( tmp , "Error in interpreter: (L %d): %s\n" , aLineno , sWhat.c_str() ); 00072 m_sWhat = tmp; 00073 } 00074 00076 virtual const char* what() const throw() 00077 { 00078 return m_sWhat.c_str(); 00079 } 00080 00082 virtual const std::string& std_what() const throw() { return m_sWhat; } 00083 }; 00084 00085 } 00086 00087 #endif
1.3.3