Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

exceptions.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 /***********************************************************************
00008  Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
00009  MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc.
00010  Others may also hold copyrights on code in this file.  See the CREDITS
00011  file in the top directory of the distribution for details.
00012 
00013  This file is part of MySQL++.
00014 
00015  MySQL++ is free software; you can redistribute it and/or modify it
00016  under the terms of the GNU Lesser General Public License as published
00017  by the Free Software Foundation; either version 2.1 of the License, or
00018  (at your option) any later version.
00019 
00020  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
00021  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00022  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00023  License for more details.
00024 
00025  You should have received a copy of the GNU Lesser General Public
00026  License along with MySQL++; if not, write to the Free Software
00027  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00028  USA
00029 ***********************************************************************/
00030 
00031 #ifndef MYSQLPP_EXCEPTIONS_H
00032 #define MYSQLPP_EXCEPTIONS_H
00033 
00034 #include "connection.h"
00035 
00036 #include <exception>
00037 #include <string>
00038 
00039 namespace mysqlpp {
00040 
00042 
00043 class MYSQLPP_EXPORT Exception : public std::exception
00044 {
00045 public:
00047         Exception(const Exception& e) throw() :
00048         std::exception(e),
00049         what_(e.what_)
00050         {
00051         }
00052 
00054         Exception& operator=(const Exception& rhs) throw()
00055         {
00056                 what_ = rhs.what_;
00057                 return *this;
00058         }
00059 
00061         ~Exception() throw() { }
00062 
00064         virtual const char* what() const throw()
00065         {
00066                 return what_.c_str();
00067         }
00068 
00069 protected:
00071         Exception(const char* w = "") throw() :
00072         what_(w)
00073         {
00074         }
00075 
00077         Exception(const std::string& w) throw() :
00078         what_(w)
00079         {
00080         }
00081 
00083         std::string what_;
00084 };
00085 
00086 
00088 
00089 class MYSQLPP_EXPORT BadConversion : public Exception
00090 {
00091 public:
00092         const char* type_name;  
00093         std::string data;               
00094         size_t retrieved;               
00095         size_t actual_size;             
00096 
00104         BadConversion(const char* tn, const char* d,
00105                         size_t r, size_t a) :
00106         Exception(std::string("Bad type conversion: ") +
00107                         std::string(d ? d : "<NULL>")),
00108         type_name(tn),
00109         data(d),
00110         retrieved(r),
00111         actual_size(a)
00112         {
00113         }
00114 
00122         BadConversion(const std::string& w, const char* tn,
00123                                   const char* d, size_t r, size_t a) :
00124         Exception(w),
00125         type_name(tn),
00126         data(d),
00127         retrieved(r),
00128         actual_size(a)
00129         {
00130         }
00131 
00137         explicit BadConversion(const char* w = "") :
00138         Exception(w),
00139         type_name("unknown"),
00140         data(""),
00141         retrieved(0),
00142         actual_size(0)
00143         {
00144         }
00145 
00147         ~BadConversion() throw() { }
00148 };
00149 
00150 
00155 
00156 class MYSQLPP_EXPORT BadFieldName : public Exception
00157 {
00158 public:
00162         explicit BadFieldName(const char* bad_field) :
00163         Exception(std::string("Unknown field name: ") + bad_field)
00164         {
00165         }
00166 
00168         ~BadFieldName() throw() { }
00169 };
00170 
00171 
00174 
00175 class MYSQLPP_EXPORT BadNullConversion : public Exception
00176 {
00177 public:
00179         explicit BadNullConversion(const char* w = "") :
00180         Exception(w)
00181         {
00182         }
00183 };
00184 
00185 
00188 
00189 class MYSQLPP_EXPORT BadOption : public Exception
00190 {
00191 public:
00193         explicit BadOption(const char* w,
00194                         Connection::Option o) :
00195         Exception(w),
00196         option_(o)
00197         {
00198         }
00199 
00201         explicit BadOption(const std::string& w,
00202                         Connection::Option o) :
00203         Exception(w),
00204         option_(o)
00205         {
00206         }
00207 
00209         Connection::Option what_option() const { return option_; }
00210 
00211 private:
00212         Connection::Option option_;
00213 };
00214 
00215 
00220 
00221 class MYSQLPP_EXPORT BadParamCount : public Exception
00222 {
00223 public:
00225         explicit BadParamCount(const char* w = "") :
00226         Exception(w)
00227         {
00228         }
00229 
00231         ~BadParamCount() throw() { }
00232 };
00233 
00234 
00241 
00242 class MYSQLPP_EXPORT BadQuery : public Exception
00243 {
00244 public:
00246         explicit BadQuery(const char* w = "") :
00247         Exception(w)
00248         {
00249         }
00250 
00252         explicit BadQuery(const std::string& w) :
00253         Exception(w)
00254         {
00255         }
00256 };
00257 
00258 
00262 
00263 class MYSQLPP_EXPORT ConnectionFailed : public Exception
00264 {
00265 public:
00267         explicit ConnectionFailed(const char* w = "") :
00268         Exception(w)
00269         {
00270         }
00271 };
00272 
00273 
00276 
00277 class MYSQLPP_EXPORT DBSelectionFailed : public Exception
00278 {
00279 public:
00281         explicit DBSelectionFailed(const char* w = "") :
00282         Exception(w)
00283         {
00284         }
00285 };
00286 
00287 
00290 
00291 class MYSQLPP_EXPORT EndOfResults : public Exception
00292 {
00293 public:
00295         explicit EndOfResults(const char* w = "end of results") :
00296         Exception(w)
00297         {
00298         }
00299 };
00300 
00301 
00304 
00305 class MYSQLPP_EXPORT EndOfResultSets : public Exception
00306 {
00307 public:
00309         explicit EndOfResultSets(const char* w = "end of result sets") :
00310         Exception(w)
00311         {
00312         }
00313 };
00314 
00315 
00323 
00324 class MYSQLPP_EXPORT LockFailed : public Exception
00325 {
00326 public:
00328         explicit LockFailed(const char* w = "lock failed") :
00329         Exception(w)
00330         {
00331         }
00332 };
00333 
00334 
00337 
00338 class MYSQLPP_EXPORT ObjectNotInitialized : public Exception
00339 {
00340 public:
00342         explicit ObjectNotInitialized(const char* w = "") :
00343         Exception(w)
00344         {
00345         }
00346 };
00347 
00348 
00349 } // end namespace mysqlpp
00350 
00351 #endif

Generated on Fri Apr 13 09:28:45 2007 for MySQL++ by doxygen 1.3.5