4
* Copyright (C) 2009 Tim Marston <tim@ed.am>
6
* This file is part of sqlite3cc (hereafter referred to as "this program").
7
* See http://ed.am/dev/sqlite3cc for more information.
9
* This program is free software: you can redistribute it and/or modify it under
10
* the terms of the GNU Lesser General Public License as published by the Free
11
* Software Foundation, either version 3 of the License, or (at your option) any
14
* This program is distributed in the hope that it will be useful, but WITHOUT
15
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
4
* Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
6
* This file is part of sqlitepp (hereafter referred to as "this program").
7
* See http://www.waxworlds.org/edam/software/sqlitepp for more information.
9
* This program is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published
11
* by the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Lesser General Public License for more details.
19
19
* You should have received a copy of the GNU Lesser General Public License
20
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#ifndef SQLITE3CC_EXCEPTION_H_
24
#define SQLITE3CC_EXCEPTION_H_
23
#ifndef EXCEPTION_HPP_
24
#define EXCEPTION_HPP_
27
27
#include <sqlite3.h>
28
28
#include <stdexcept>
40
36
* Main (base) sqlite exception class.
51
* Constructor that takes an sqlite result code and a connection from which
52
* to determine it's error message.
54
* @param connection a reference to a connection
55
* @param code the sqlite result code
56
* @see sqlite_errmsg()
58
explicit sqlite_error(
59
connection &connection,
64
* Constructor that takes an sqlite result code and determines it's own
65
* generic error message.
67
* @param code the sqlite result code
69
explicit sqlite_error(
73
* Constructor that allows the creation of an sqlite result with a custom
47
* Constructor that takes an sqlite error code and determines it's own
49
* @param error_code the sqlite error code
55
* Constructor that allows the creation of an sqlite error with a custom
76
57
* @param message a customer error message string
77
* @param code the sqlite result code
58
* @param error_code the sqlite error code
79
explicit sqlite_error(
80
61
const std::string &message,
81
int code = SQLITE_ERROR );
62
int error_code = SQLITE_ERROR );
83
64
virtual ~sqlite_error() throw( );
90
* Get the sqlite result code associated with this error.
92
* @returns the sqlite result code
71
* Get the sqlite error code associated with this error
72
* @returns the sqlite error code
74
int get_error_code() const;
97
77
* Get the error message
107
* Retrieve an automatic error message for a given sqlite result code.
109
* @param the sqlite result code
87
* Retrieve an automatic error message for a given sqlite error code
88
* @param the sqlite error code
110
89
* @returns the automatic string
112
const std::string &get_message(
91
const std::string &get_error_message(
115
/** the result code */
118
97
/** the message string */
119
98
std::string _message;