00001 // ServiceException.h 00002 00003 00004 #ifndef SERVICEEXCEPTION_H 00005 #define SERVICEEXCEPTION_H 00006 00007 #include <exception> 00008 #include <string> 00009 00010 namespace Yosokumo 00011 { 00012 /** 00013 * Encapsulates all exceptions which can be thrown by the Yosokumo Service. 00014 */ 00015 00016 class ServiceException : public std::exception 00017 { 00018 std::string detailMessage; 00019 std::string failedMethodName; 00020 int statusCode; 00021 00022 public: 00023 00024 /** 00025 * Constructs a new default exception. 00026 */ 00027 ServiceException(); 00028 00029 /** 00030 * Constructs a new exception with the specified detail message. 00031 * 00032 * @param message the detail message. The detail message is saved for 00033 * later retrieval by the <code>what()</code> method. 00034 */ 00035 ServiceException(const std::string &message); 00036 00037 /** 00038 * Constructs a new exception with the specified detail message and 00039 * failed method name. 00040 * 00041 * @param message the detail message (which is saved for later retrieval 00042 * by the <code>what()</code> method. 00043 * @param failedMethodName the name of the method which failed 00044 * with the exception. 00045 */ 00046 ServiceException( 00047 const std::string &message, 00048 const std::string &failedMethodName); 00049 00050 /** 00051 * Constructs a new exception with the specified detail message, 00052 * status code, and failed method name. 00053 * 00054 * @param message the detail message (which is saved for later retrieval 00055 * by the <code>what()</code> method. 00056 * @param statusCode the status code from most recent HTTP response. 00057 * A zero means the most recent HTTP request did not 00058 * result in a response, e.g., there is no network 00059 * connection. 00060 * @param failedMethodName the name of the Service method which failed 00061 * with the exception. 00062 */ 00063 ServiceException( 00064 const std::string &message, 00065 int statusCode, 00066 const std::string &failedMethodName); 00067 00068 /** 00069 * Copy constructor - initializes a newly created 00070 * <code>ServiceException</code> object with a copy of another 00071 * <code>ServiceException</code> object. 00072 * 00073 * @param rhs the <code>ServiceException</code> to make a copy of. 00074 */ 00075 ServiceException(const ServiceException &rhs) throw(); 00076 00077 /** 00078 * Destructor - destroy a <code>ServiceException</code> object. 00079 */ 00080 virtual ~ServiceException() throw(); 00081 00082 /** 00083 * Assignment operator - assign one <code>ServiceException</code> to 00084 * another. 00085 * 00086 * @param rhs the righthand side of the assignment. 00087 * 00088 * @return a reference to <code>this</code> ServiceException. 00089 */ 00090 ServiceException& operator=(const ServiceException& rhs) throw(); 00091 00092 // getters 00093 00094 /** 00095 * Return message telling what exception occurred. 00096 * 00097 * @return message telling what exception occurred. 00098 */ 00099 const char* what() const throw(); 00100 00101 /** 00102 * Return HTTP status code. 00103 * 00104 * @return status code from most recent HTTP response. A zero means 00105 * the most recent HTTP request did not result in a response, 00106 * e.g., there is no network connection. 00107 */ 00108 int getStatusCode() const; 00109 00110 /** 00111 * Return the name of the Service method which failed with this exception. 00112 * 00113 * @return name of the Service method which failed. 00114 */ 00115 std::string getFailedMethodName() const; 00116 00117 }; // end class ServiceException 00118 00119 } // end namespace Yosokumo 00120 00121 #endif // SERVICEEXCEPTION_H 00122 00123 // end ServiceException.h