/sqlite3cc

To get this branch, use:
bzr branch http://bzr.ed.am/sqlite3cc

« back to all changes in this revision

Viewing changes to include/sqlite3cc/exception.h

  • Committer: Tim Marston
  • Date: 2015-02-26 08:59:16 UTC
  • Revision ID: tim@ed.am-20150226085916-1z7761knxbutpr7n
updated tests for blob support

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * exception.h
3
3
 *
4
 
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
 
4
 * Copyright (C) 2009 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of sqlite3cc (hereafter referred to as "this program").
7
 
 * See http://www.waxworlds.org/edam/software/sqlite3cc for more information.
8
 
 *
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.
13
 
 *
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.
 
7
 * See http://ed.am/dev/sqlite3cc for more information.
 
8
 *
 
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
 
12
 * later version.
 
13
 *
 
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
 
17
 * details.
18
18
 *
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/>.
32
32
{
33
33
 
34
34
 
 
35
class connection;
 
36
 
 
37
 
35
38
/**
36
39
 * Main (base) sqlite exception class.
37
40
 */
44
47
public:
45
48
 
46
49
        /**
47
 
         * Constructor that takes an sqlite error code and determines it's own
48
 
         * error message
49
 
         * @param error_code the sqlite error code
50
 
         */
51
 
        explicit sqlite_error(
52
 
                int error_code );
53
 
 
54
 
        /**
55
 
         * Constructor that allows the creation of an sqlite error with a custom
 
50
         * Constructor that takes an sqlite result code and a connection from which
 
51
         * to determine it's error message.
 
52
         *
 
53
         * @param connection a reference to a connection
 
54
         * @param code the sqlite result code
 
55
         * @see sqlite_errmsg()
 
56
         */
 
57
        explicit sqlite_error(
 
58
                connection &connection,
 
59
                int code );
 
60
 
 
61
 
 
62
        /**
 
63
         * Constructor that takes an sqlite result code and determines it's own
 
64
         * generic error message.
 
65
         *
 
66
         * @param code the sqlite result code
 
67
         */
 
68
        explicit sqlite_error(
 
69
                int code );
 
70
 
 
71
        /**
 
72
         * Constructor that allows the creation of an sqlite result with a custom
56
73
         * message.
 
74
         *
57
75
         * @param message a customer error message string
58
 
         * @param error_code the sqlite error code
 
76
         * @param code the sqlite result code
59
77
         */
60
78
        explicit sqlite_error(
61
79
                const std::string &message,
62
 
                int error_code = SQLITE_ERROR );
 
80
                int code = SQLITE_ERROR );
63
81
 
64
82
        virtual ~sqlite_error() throw( );
65
83
 
68
86
public:
69
87
 
70
88
        /**
71
 
         * Get the sqlite error code associated with this error
72
 
         * @returns the sqlite error code
 
89
         * Get the sqlite result code associated with this error.
 
90
         *
 
91
         * @returns the sqlite result code
73
92
         */
74
 
        int get_error_code() const;
 
93
        int get_code() const;
75
94
 
76
95
        /**
77
96
         * Get the error message
84
103
private:
85
104
 
86
105
        /**
87
 
         * Retrieve an automatic error message for a given sqlite error code
88
 
         * @param the sqlite error code
 
106
         * Retrieve an automatic error message for a given sqlite result code.
 
107
         *
 
108
         * @param the sqlite result code
89
109
         * @returns the automatic string
90
110
         */
91
 
        const std::string &get_error_message(
92
 
                int error_code );
 
111
        const std::string &get_message(
 
112
                int code );
93
113
 
94
 
        /** the error code */
95
 
        int _error_code;
 
114
        /** the result code */
 
115
        int _code;
96
116
 
97
117
        /** the message string */
98
118
        std::string _message;