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

# exceptions.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007
    00008 /***********************************************************************
    00009  Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
    00010  MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc.
    00011  Others may also hold copyrights on code in this file.  See the CREDITS
    00012  file in the top directory of the distribution for details.
    00013
    00014  This file is part of MySQL++.
    00015
    00016  MySQL++ is free software; you can redistribute it and/or modify it
    00017  under the terms of the GNU Lesser General Public License as published
    00018  by the Free Software Foundation; either version 2.1 of the License, or
    00019  (at your option) any later version.
    00020
    00021  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00022  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00023  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00024  License for more details.
    00025
    00026  You should have received a copy of the GNU Lesser General Public
    00027  License along with MySQL++; if not, write to the Free Software
    00028  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00029  USA
    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 } // end namespace mysqlpp
    00216
    00217 #endif