Kompex SQLite Wrapper  1.11.14
KompexSQLiteException.h
Go to the documentation of this file.
1 /*
2  This file is part of Kompex SQLite Wrapper.
3  Copyright (c) 2008-2015 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 lineNumber, std::string errDescription = "", int internalSqliteResultCode = -1):
36  mErrorDescription(errDescription),
37  mFilename(filename),
38  mLineNumber(lineNumber),
39  mInternalSqliteResultCode(internalSqliteResultCode)
40  {
41  }
42 
44  SQLiteException(const std::string &filename, unsigned int lineNumber, const char *errDescription = "", int internalSqliteResultCode = -1):
45  mErrorDescription(std::string(errDescription)),
46  mFilename(filename),
47  mLineNumber(lineNumber),
48  mInternalSqliteResultCode(internalSqliteResultCode)
49  {
50  }
51 
54  inline void Show() const {std::cerr << "file: " << mFilename << "\nline number: " << mLineNumber << "\nerror: " << mErrorDescription << std::endl;}
55 
57  std::string GetString() const
58  {
59  std::stringstream strStream;
60  strStream << "file: " << mFilename << "\nline number: " << mLineNumber << "\nerror: " << std::string(mErrorDescription) << "\n";
61  return strStream.str();
62  }
63 
65  std::string GetErrorDescription() const {return mErrorDescription;}
66 
68  std::string GetFilename() const {return mFilename;}
69 
71  unsigned int GetLineNumber() const {return mLineNumber;}
72 
78  int GetSqliteResultCode() const {return mInternalSqliteResultCode;}
79 
80  private:
82  std::string mErrorDescription;
84  std::string mFilename;
86  unsigned int mLineNumber;
89  };
90 };
91 
92 #endif // KompexSQLiteException_H
93 
94 #ifndef KOMPEX_EXCEPT
95 #define KOMPEX_EXCEPT(errorString, internalSqliteResultCode) throw SQLiteException(__FILE__, __LINE__, errorString, internalSqliteResultCode)
96 #endif
SQLiteException(const std::string &filename, unsigned int lineNumber, std::string errDescription="", int internalSqliteResultCode=-1)
Overloaded constructor.
Definition: KompexSQLiteException.h:35
std::string mErrorDescription
Error description.
Definition: KompexSQLiteException.h:82
unsigned int mLineNumber
Line number in which the error occured.
Definition: KompexSQLiteException.h:86
SQLiteException(const std::string &filename, unsigned int lineNumber, const char *errDescription="", int internalSqliteResultCode=-1)
Overloaded constructor.
Definition: KompexSQLiteException.h:44
std::string GetString() const
Get all error information (filename, line, error message) as std::string.
Definition: KompexSQLiteException.h:57
std::string mFilename
Filename in which the error occured.
Definition: KompexSQLiteException.h:84
void Show() const
Definition: KompexSQLiteException.h:54
#define _SQLiteWrapperExport
Definition: KompexSQLitePrerequisites.h:32
std::string GetFilename() const
Returns the filename in which the error occured.
Definition: KompexSQLiteException.h:68
Exception class for sqlite and KompexSQLiteWrapper errors.
Definition: KompexSQLiteException.h:31
int mInternalSqliteResultCode
Internal SQLite result code.
Definition: KompexSQLiteException.h:88
int GetSqliteResultCode() const
Definition: KompexSQLiteException.h:78
std::string GetErrorDescription() const
Returns an error description.
Definition: KompexSQLiteException.h:65
Definition: KompexSQLiteBlob.h:26
unsigned int GetLineNumber() const
Returns the line number in which the error occured.
Definition: KompexSQLiteException.h:71