Kompex SQLite Wrapper  1.9.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
KompexSQLiteException.h
Go to the documentation of this file.
1 /*
2  This file is part of Kompex SQLite Wrapper.
3  Copyright (c) 2008-2013 Sven Broeske
4 
5  Kompex SQLite Wrapper is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Kompex SQLite Wrapper is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Kompex SQLite Wrapper. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef KompexSQLiteException_H
20 #define KompexSQLiteException_H
21 
22 #include <map>
23 #include <string>
24 #include <sstream>
25 #include <iostream>
27 
28 namespace Kompex
29 {
32  {
33  public:
35  SQLiteException(const std::string &filename, unsigned int line, std::string errDescription = ""):
36  mErrorDescription(errDescription),
37  mFilename(filename),
38  mLine(line)
39  {
40  }
41 
43  SQLiteException(const std::string &filename, unsigned int line, const char *errDescription = ""):
44  mErrorDescription(std::string(errDescription)),
45  mFilename(filename),
46  mLine(line)
47  {
48  }
49 
52  inline void Show() const {std::cerr << "file: " << mFilename << "\nline: " << mLine << "\nerror: " << mErrorDescription << std::endl;}
54  std::string GetString() const
55  {
56  std::stringstream strStream;
57  strStream << "file: " << mFilename << "\nline: " << mLine << "\nerror: " << std::string(mErrorDescription) << "\n";
58  return strStream.str();
59  }
60 
61  private:
63  std::string mErrorDescription;
65  std::string mFilename;
67  unsigned int mLine;
68  };
69 };
70 
71 #endif // KompexSQLiteException_H
72 
73 #ifndef KOMPEX_EXCEPT
74 #define KOMPEX_EXCEPT(errorString) throw SQLiteException(__FILE__, __LINE__, errorString)
75 #endif