/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: edam
  • Date: 2010-07-29 06:28:53 UTC
  • Revision ID: edam@waxworlds.org-20100729062853-4i2fec52m86mh724
- made basic_statement::step() protected, for use by query and command only
- moved basic_statement::operator<<() to command and query instead; one needs to accept sqlite::exec, the other doesn't
- added tests for query::operator<<()
- added code to invlaidate in-progress queries during any transaction rollbacks (currently segfaults in basic_statement::finalize())
- added new sqlite_error constructor that obtains a full error message
- implemented database::database_mutex_guard class
- swapped command's step mutex in favour of the database mutex

Show diffs side-by-side

added added

removed removed

32
32
{
33
33
 
34
34
 
 
35
class database;
 
36
 
 
37
 
35
38
/**
36
39
 * Main (base) sqlite exception class.
37
40
 */
44
47
public:
45
48
 
46
49
        /**
 
50
         * Constructor that takes an sqlite error code and a database from which to
 
51
         * determine it's error message
 
52
         * @param code the sqlite error code
 
53
         * @see sqlite_errmsg()
 
54
         */
 
55
        explicit sqlite_error(
 
56
                database &database,
 
57
                int code );
 
58
 
 
59
 
 
60
        /**
47
61
         * Constructor that takes an sqlite error code and determines it's own
48
 
         * error message
49
 
         * @param error_code the sqlite error code
 
62
         * generic error message
 
63
         * @param code the sqlite error code
50
64
         */
51
65
        explicit sqlite_error(
52
 
                int error_code );
 
66
                int code );
53
67
 
54
68
        /**
55
69
         * Constructor that allows the creation of an sqlite error with a custom
56
70
         * message.
57
71
         * @param message a customer error message string
58
 
         * @param error_code the sqlite error code
 
72
         * @param code the sqlite error code
59
73
         */
60
74
        explicit sqlite_error(
61
75
                const std::string &message,
62
 
                int error_code = SQLITE_ERROR );
 
76
                int code = SQLITE_ERROR );
63
77
 
64
78
        virtual ~sqlite_error() throw( );
65
79
 
71
85
         * Get the sqlite error code associated with this error
72
86
         * @returns the sqlite error code
73
87
         */
74
 
        int get_error_code() const;
 
88
        int get_code() const;
75
89
 
76
90
        /**
77
91
         * Get the error message
88
102
         * @param the sqlite error code
89
103
         * @returns the automatic string
90
104
         */
91
 
        const std::string &get_error_message(
92
 
                int error_code );
 
105
        const std::string &get_message(
 
106
                int code );
93
107
 
94
108
        /** the error code */
95
 
        int _error_code;
 
109
        int _code;
96
110
 
97
111
        /** the message string */
98
112
        std::string _message;
100
114
};
101
115
 
102
116
 
103
 
/**
104
 
 * An sqlite error that indicates the database was busy
105
 
 */
106
 
class sqlite_busy
107
 
        :
108
 
        public sqlite_error
109
 
{
110
 
public:
111
 
        sqlite_busy()
112
 
                :
113
 
                sqlite_error( "database was busy", SQLITE_BUSY )
114
 
        { }
115
 
};
116
 
 
117
 
 
118
117
} // namespace sqlite
119
118
 
120
119