00001 #ifndef ISPN_HOTROD_EXCEPTIONS_H
00002 #define ISPN_HOTROD_EXCEPTIONS_H
00003
00004 #include <exception>
00005 #include <string>
00006 #include <stdint.h>
00007 #include "infinispan/hotrod/defs.h"
00008 #include "infinispan/hotrod/portable.h"
00009 #include "infinispan/hotrod/ImportExport.h"
00010
00011 namespace infinispan {
00012 namespace hotrod {
00013
00014 class HR_EXTERN Exception : public std::exception
00015 {
00016 public:
00017 explicit Exception(const std::string& message=std::string()) throw();
00018 virtual ~Exception() throw();
00019 virtual const char* what() const throw();
00020
00021 protected:
00022 portable::string message;
00023 };
00024
00029 class HR_EXTERN HotRodClientException : public Exception
00030 {
00031 public:
00032 explicit HotRodClientException(const std::string&);
00033 HotRodClientException(const std::string& message_, uint64_t message_id_, uint8_t status_);
00034 virtual ~HotRodClientException() throw();
00035 virtual const char* what() const throw();
00036 private:
00037 uint64_t message_id;
00038 uint8_t status;
00039 };
00040
00046 class HR_EXTERN TransportException : public HotRodClientException
00047 {
00048 public:
00049 TransportException(const std::string& host, int port, const std::string&);
00050 ~TransportException() throw();
00051
00052 const std::string &getHost() const {
00053 if (hostPtr.get() == NULL) {
00054 const_cast<TransportException *>(this)->hostPtr.set(new std::string(host.c_string()), &deleteString);
00055 }
00056 return *(hostPtr.get());
00057 }
00058 const char *getHostCString() const;
00059 int getPort() const;
00060 private:
00061 const portable::string host;
00062 __pragma(warning(suppress:4251))
00063 portable::local_ptr<std::string> hostPtr;
00064 int port;
00065
00066 static void deleteString(std::string *str) { delete str; }
00067 };
00068
00074 class HR_EXTERN InvalidResponseException : public HotRodClientException
00075 {
00076 public:
00077 InvalidResponseException(const std::string&);
00078 };
00079
00085 class HR_EXTERN RemoteNodeSuspectException : public HotRodClientException
00086 {
00087 public:
00088 RemoteNodeSuspectException(const std::string&, uint64_t message_id, uint8_t status);
00089 };
00090
00095 class HR_EXTERN InternalException : public HotRodClientException
00096 {
00097 public:
00098 InternalException(const std::string&);
00099 };
00100
00107 class HR_EXTERN RemoteCacheManagerNotStartedException : public HotRodClientException
00108 {
00109 public:
00110 RemoteCacheManagerNotStartedException(const std::string&);
00111 };
00112
00117 struct HR_EXTERN UnsupportedOperationException : public HotRodClientException
00118 {
00119 UnsupportedOperationException();
00120 };
00121
00122 }}
00123
00124 #endif