00001 #ifndef __GEMFIRE_EXCEPTION_H__
00002 #define __GEMFIRE_EXCEPTION_H__
00003
00004
00005
00006
00007
00008
00013 #include "gfcpp_globals.hpp"
00014 #include "gf_types.hpp"
00015
00016 namespace gemfire {
00017
00018 #define GF_EX_MSG_LIMIT 2048
00019
00020 class Exception;
00021 typedef SharedPtr<Exception> ExceptionPtr;
00022
00023 class DistributedSystem;
00024
00029 class CPPCACHE_EXPORT Exception : public SharedBase
00030 {
00034 public:
00035
00044 Exception(const char* msg1, const char* msg2 = NULL,
00045 bool forceTrace = false, const ExceptionPtr& cause = NULLPTR);
00046
00051 Exception( const Exception& other );
00052
00054 virtual Exception* clone() const;
00055
00059 virtual ~Exception();
00060
00065 virtual const char * getMessage() const;
00069 virtual void showMessage() const;
00070
00074 virtual void printStackTrace() const;
00075
00076 #ifndef _SOLARIS
00077
00080 virtual size_t getStackTrace( char* buffer, size_t maxLength ) const;
00081 #endif
00082
00084 virtual const char* getName( ) const;
00085
00090 virtual void raise()
00091 {
00092 throw *this;
00093 }
00094
00095 inline ExceptionPtr getCause() const
00096 {
00097 return m_cause;
00098 }
00099
00100 protected:
00102 Exception(const CacheableStringPtr& message, const StackTracePtr& stack,
00103 const ExceptionPtr& cause);
00104
00105 static bool s_exceptionStackTraceEnabled;
00106
00107 CacheableStringPtr m_message;
00108 StackTracePtr m_stack;
00109 ExceptionPtr m_cause;
00110
00111 private:
00112 static void setStackTraces(bool stackTraceEnabled);
00113
00114 friend class DistributedSystem;
00115 };
00116
00117 }
00118
00119 #endif //ifndef __GEMFIRE_EXCEPTION_H__