00001 /* Copyright (C) GridGain Systems. All Rights Reserved. */ 00002 00003 /* _________ _____ __________________ _____ 00004 * __ ____/___________(_)______ /__ ____/______ ____(_)_______ 00005 * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ 00006 * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / 00007 * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ 00008 */ 00009 00010 #ifndef GRIDCLIENTEXCEPTION_HPP_INCLUDED 00011 #define GRIDCLIENTEXCEPTION_HPP_INCLUDED 00012 00013 #include <string> 00014 #include <exception> 00015 00016 #include <gridgain/gridconf.hpp> 00017 #include <boost/exception/exception.hpp> 00018 00022 #ifdef _MSC_VER 00023 class GRIDGAIN_API GridClientException : 00024 public std::exception, 00025 public boost::exception_detail::clone_base { 00026 public: 00028 GridClientException() : exception("Unknown grid exception") { 00029 } 00030 00036 GridClientException(std::string what): exception(what.c_str()) { 00037 } 00038 00048 virtual clone_base const * clone() const { 00049 return new GridClientException(what()); 00050 } 00051 00055 virtual void rethrow() const { 00056 throw *this; 00057 } 00058 }; 00059 #else 00060 class GRIDGAIN_API GridClientException: 00061 public std::exception, 00062 public boost::exception_detail::clone_base { 00063 public: 00065 GridClientException() 00066 : what_("Unknown grid exception") { 00067 } 00068 00074 GridClientException(const std::string& what) 00075 : what_(what) { 00076 } 00077 00078 ~GridClientException() throw () { 00079 } 00080 00081 virtual const char* what() const throw () { 00082 return what_.c_str(); 00083 } 00084 00094 virtual clone_base const * clone() const { 00095 return new GridClientException(what()); 00096 } 00097 00101 virtual void rethrow() const { 00102 throw *this; 00103 } 00104 00105 private: 00106 std::string what_; 00107 }; 00108 00109 #endif 00110 00114 class GRIDGAIN_API GridServerUnreachableException: public GridClientException { 00115 public: 00116 GridServerUnreachableException(const std::string& what) 00117 : GridClientException(what) { 00118 } 00119 00120 virtual const char* what() const throw () { 00121 return "Server is not reachable"; 00122 } 00123 }; 00124 00128 class GRIDGAIN_API GridClientClosedException: public GridClientException { 00129 public: 00130 virtual const char* what() const throw () { 00131 return "Connection closed"; 00132 } 00133 00137 virtual clone_base const * clone() const { 00138 return new GridClientClosedException(); 00139 } 00140 00144 virtual void rethrow() const { 00145 throw *this; 00146 } 00147 }; 00148 00152 class GRIDGAIN_API GridConnectionIdleClosedException: public GridClientException { 00153 public: 00154 virtual const char* what() const throw () { 00155 return "Connection closed after idle"; 00156 } 00157 }; 00158 00162 class GRIDGAIN_API GridClientConnectionResetException: public GridClientException { 00163 public: 00169 GridClientConnectionResetException(const std::string& what) 00170 : GridClientException(what) { 00171 } 00172 }; 00173 00177 class GRIDGAIN_API GridClientCommandException: public GridClientException { 00178 public: 00184 GridClientCommandException(const std::string& what) 00185 : GridClientException(what) { 00186 } 00187 }; 00188 00194 class GRIDGAIN_API GridClientFutureTimeoutException: public GridClientException { 00195 public: 00196 virtual const char* what() const throw () { 00197 return "Future timed out"; 00198 } 00199 }; 00200 00201 #endif // GRIDCLIENTEXCEPTION_HPP_INCLUDED
1.7.1