Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

/home/tommi/tntdb/include/tntdb/error.h

00001 /*
00002  * Copyright (C) 2005 Tommi Maekitalo
00003  * 
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  * 
00009  * As a special exception, you may use this file as part of a free
00010  * software library without restriction. Specifically, if other files
00011  * instantiate templates or use macros or inline functions from this
00012  * file, or you compile this file and link it with other files to
00013  * produce an executable, this file does not by itself cause the
00014  * resulting executable to be covered by the GNU General Public
00015  * License. This exception does not however invalidate any other
00016  * reasons why the executable file might be covered by the GNU Library
00017  * General Public License.
00018  * 
00019  * This library is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * Lesser General Public License for more details.
00023  * 
00024  * You should have received a copy of the GNU Lesser General Public
00025  * License along with this library; if not, write to the Free Software
00026  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00027  */
00028 
00029 #ifndef TNTDB_ERROR_H
00030 #define TNTDB_ERROR_H
00031 
00032 #include <stdexcept>
00033 #include <string>
00034 
00035 namespace tntdb
00036 {
00041   class Error : public std::runtime_error
00042   {
00043     public:
00045       explicit Error(const std::string& msg);
00046   };
00047 
00051   class NotFound : public Error
00052   {
00053     public:
00054       NotFound();
00055   };
00056 
00061   class NullValue : public Error
00062   {
00063     public:
00064       NullValue();
00065   };
00066 
00070   class TypeError : public Error
00071   {
00072     public:
00073       explicit TypeError(const std::string& msg = "type error");
00074   };
00075 
00079   class SqlError : public Error
00080   {
00081       std::string sql;
00082 
00083     public:
00084       explicit SqlError(const std::string& sql_, const std::string& msg = "sql error");
00085       ~SqlError() throw()
00086         { }
00087 
00088       const std::string& getSql() const  { return sql; }
00089   };
00090 
00091   class FieldNotFound : public Error
00092   {
00093       std::string field;
00094 
00095     public:
00096       explicit FieldNotFound(const std::string& field);
00097       ~FieldNotFound() throw() { }
00098 
00099       const std::string& getField() const   { return field; }
00100   };
00101 }
00102 
00103 #endif // TNTDB_ERROR_H
00104 
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6