00001 /*------------------------------------------------------------------------------ 00002 Name: XmlBlasterException.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: Basic xmlBlaster exception. 00006 ------------------------------------------------------------------------------*/ 00007 00042 #ifndef _UTIL_XMLBLASTER_EXCEPTION_H 00043 #define _UTIL_XMLBLASTER_EXCEPTION_H 00044 00045 #include <string> 00046 // #include <util/Timestamp.h> 00047 #include <util/ErrorCode.h> 00048 #include <stdexcept> 00049 00050 namespace org { namespace xmlBlaster { namespace util { 00051 00052 class Dll_Export XmlBlasterException : public std::exception 00053 { 00054 private: 00055 const std::string errorCodeStr_; 00056 const std::string node_; 00057 std::string location_; 00058 const std::string lang_; 00059 const std::string message_; 00060 const std::string versionInfo_; 00061 mutable std::string timestamp_; 00062 std::string stackTrace_; 00063 std::string embeddedMessage_; 00064 const std::string transactionInfo_; 00065 mutable std::string str_; // for what(), holds memory for const char * return 00066 00067 public: 00068 00072 XmlBlasterException(const std::string &errorCodeStr, 00073 const std::string &node, 00074 const std::string &location, 00075 const std::string &lang="en", 00076 const std::string &message="", 00077 const std::string &versionInfo="@version@", // is replaced by ant / build.xml to e.g. "0.85c", see org::xmlBlaster::util::Global.getVersion(), 00078 // org::xmlBlaster::util::Timestamp timestamp=0, 00079 const std::string ×tampStr="", 00080 const std::string &stackTrace="", 00081 const std::string &embeddedMessage="", 00082 const std::string &transactionInfo="<transactioninfo/>"); 00083 00084 XmlBlasterException(const ErrorCode &errorCode, 00085 const std::string &node, 00086 const std::string &location, 00087 const std::string &lang, 00088 const std::string &versionInfo="@version@", // is replaced by ant / build.xml to e.g. "0.85c", see org::xmlBlaster::util::Global.getVersion(), 00089 // org::xmlBlaster::util::Timestamp timestamp=0, 00090 const std::string ×tampStr="", 00091 const std::string &stackTrace="", 00092 const std::string &embeddedMessage="", 00093 const std::string &transactionInfo="<transactioninfo/>"); 00094 00095 XmlBlasterException(const ErrorCode &errorCode, 00096 const std::string &node, 00097 const std::string &embeddedMessage); 00098 00099 virtual ~XmlBlasterException() throw(); 00100 00101 std::string getErrorCodeStr() const; 00102 std::string getNode() const; 00103 void setLocation(const std::string& location) { this->location_ = location; } 00104 std::string getLocation() const; 00105 std::string getLang() const; 00106 std::string getMessage() const; 00107 00111 std::string getRawMessage() const; 00112 00117 std::string getVersionInfo() const; 00118 00122 std::string getTimestamp() const; 00123 00133 std::string getStackTraceStr() const; 00134 00139 std::string getEmbeddedMessage() const; 00140 00144 std::string getTransactionInfo() const; 00145 00146 bool isInternal() const; 00147 00148 bool isResource() const; 00149 00150 bool isCommunication() const; 00151 00152 bool isUser() const; 00153 00154 bool isTransaction() const; 00155 00160 const char *what() const throw(); 00161 00165 std::string toString() const; 00166 00170 static XmlBlasterException parseFromString(std::string fromString); 00171 00181 std::string toXml() const; 00182 00188 static std::string getStackTrace(int maxNumOfLines=20); 00189 00190 }; 00191 00192 }}} // namespaces 00193 00194 #endif