00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef MYSQLPP_EXCEPTIONS_H
00033 #define MYSQLPP_EXCEPTIONS_H
00034
00035 #include <exception>
00036 #include <string>
00037
00038 namespace mysqlpp {
00039
00046
00047 class BadQuery : public std::exception
00048 {
00049 public:
00051 BadQuery(const std::string & er = "") :
00052 error(er)
00053 {
00054 }
00055
00057 ~BadQuery() throw()
00058 {
00059 }
00060
00062 virtual const char* what() const throw() { return error.c_str(); }
00063
00064 const std::string error;
00065 };
00066
00067
00069
00070 class BadConversion : public std::exception
00071 {
00072 private:
00073 const std::string _what;
00074
00075 public:
00076 const char* type_name;
00077 const std::string data;
00078 size_t retrieved;
00079 size_t actual_size;
00080
00088 BadConversion(const char* tn, const char* d, size_t r,
00089 size_t a) :
00090 _what(std::string("Tried to convert \"") + std::string(d ? d : "") +
00091 "\" to a \"" + std::string(tn ? tn : "")),
00092 type_name(tn),
00093 data(d),
00094 retrieved(r),
00095 actual_size(a)
00096 {
00097 }
00098
00106 BadConversion(const std::string& wt, const char* tn,
00107 const char* d, size_t r, size_t a) :
00108 _what(wt),
00109 type_name(tn),
00110 data(d),
00111 retrieved(r),
00112 actual_size(a)
00113 {
00114 }
00115
00121 BadConversion(const std::string& wt = "") :
00122 _what(wt),
00123 type_name("unknown"),
00124 data(""),
00125 retrieved(0),
00126 actual_size(0)
00127 {
00128 }
00129
00131 ~BadConversion() throw() { }
00132
00134 virtual const char *what() const throw() { return _what.c_str(); }
00135 };
00136
00137
00140
00141 class BadNullConversion : public std::exception
00142 {
00143 private:
00144 const std::string _what;
00145
00146 public:
00148 BadNullConversion(const std::string& wt = "") :
00149 _what(wt)
00150 {
00151 }
00152
00154 ~BadNullConversion() throw() { }
00155
00157 virtual const char* what() const throw() { return _what.c_str(); }
00158 };
00159
00160
00165
00166 class SQLQueryNEParms : public std::exception
00167 {
00168 private:
00169 const std::string _what;
00170
00171 public:
00173 SQLQueryNEParms(const char* c) :
00174 _what(std::string(c ? c : "")),
00175 error(c)
00176 {
00177 }
00178
00180 ~SQLQueryNEParms() throw() { }
00181
00183 virtual const char* what() const throw() { return _what.c_str(); }
00184
00185 const char* error;
00186 };
00187
00188
00193
00194 class BadFieldName : public std::exception
00195 {
00196 private:
00197 std::string _what;
00198
00199 public:
00202 BadFieldName(const char* bad_field)
00203 {
00204 _what = "Unknown field name: ";
00205 _what += bad_field;
00206 }
00207
00209 ~BadFieldName() throw() { }
00210
00212 virtual const char* what() const throw() { return _what.c_str(); }
00213 };
00214
00215 }
00216
00217 #endif