00001 #ifndef _SUIF_EXCEPTION_H_ 00002 #define _SUIF_EXCEPTION_H_ 00003 #include <stdlib.h> 00004 #include "common/MString.h" 00005 #include "message_buffer.h" 00006 #include "suifkernel_messages.h" 00007 00008 #ifdef USE_CPP_EXCEPTION 00009 #define SUIF_THROW(exp) throw exp 00010 #else // USE_CPP_EXCEPTION 00011 #define SUIF_THROW(exp) { \ 00012 suif_error("%s", exp.get_message().c_str()); \ 00013 exit(1); \ 00014 } 00015 #endif // USE_CPP_EXCEPTION 00016 00017 00018 00019 00020 class SuifException; 00021 00022 class SuifException { 00023 public: 00024 SuifException(String msg); 00025 SuifException(String effect, SuifException *cause); 00026 SuifException(MessageBuffer *mbuf); 00027 SuifException(const SuifException&); 00028 virtual ~SuifException(void); 00029 00030 virtual String get_message(void); 00031 virtual MessageBuffer *get_message_buffer(void); 00032 private: 00033 MessageBuffer *_msgbuf; 00034 }; 00035 00036 00037 00038 class SuifDevException : public SuifException { 00039 public: 00040 SuifDevException(const char* file, int line, String msg); 00041 SuifDevException(const char* file, int line, SuifException *cause); 00042 SuifDevException(const char* file, int line, MessageBuffer *mbuf); 00043 SuifDevException(const SuifDevException& that); 00044 }; 00045 00046 00047 00048 00049 00050 00051 #endif // _SUIF_EXCEPTION_H_