00001 #ifndef __GEMFIRE_EXCEPTION_H__
00002 #define __GEMFIRE_EXCEPTION_H__
00003
00004
00005
00006
00007
00008
00009
00010
00015 #include "gfcpp_globals.hpp"
00016 #include "gf_types.hpp"
00017
00018 namespace gemfire {
00019
00020 #define GF_EX_MSG_LIMIT 2048
00021
00022 class Exception;
00023 typedef SharedPtr<Exception> ExceptionPtr;
00024
00025 class DistributedSystem;
00026
00031 class CPPCACHE_EXPORT Exception : public SharedBase
00032 {
00036 public:
00037
00046 Exception(const char* msg1, const char* msg2 = NULL,
00047 bool forceTrace = false, const ExceptionPtr& cause = NULLPTR);
00048
00053 Exception( const Exception& other );
00054
00056 virtual Exception* clone() const;
00057
00061 virtual ~Exception();
00062
00067 virtual const char * getMessage() const;
00071 virtual void showMessage() const;
00072
00076 virtual void printStackTrace() const;
00077
00078 #ifndef _SOLARIS
00079
00082 virtual size_t getStackTrace( char* buffer, size_t maxLength ) const;
00083 #endif
00084
00086 virtual const char* getName( ) const;
00087
00092 virtual void raise()
00093 {
00094 throw *this;
00095 }
00096
00097 inline ExceptionPtr getCause() const
00098 {
00099 return m_cause;
00100 }
00101
00102 protected:
00104 Exception(const CacheableStringPtr& message, const StackTracePtr& stack,
00105 const ExceptionPtr& cause);
00106
00107 static bool s_exceptionStackTraceEnabled;
00108
00109 CacheableStringPtr m_message;
00110 StackTracePtr m_stack;
00111 ExceptionPtr m_cause;
00112
00113 private:
00114 static void setStackTraces(bool stackTraceEnabled);
00115
00116 friend class DistributedSystem;
00117 };
00118
00119 }
00120
00121 #endif //ifndef __GEMFIRE_EXCEPTION_H__