/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-01-28 12:21:03 UTC
  • Revision ID: edam@waxworlds.org-20100128122103-v3gs6hro5h7ffnhb
- further initial development
- basic support for: queries, rows (query results)
- filename, comment header and project name consistency

Show diffs side-by-side

added added

removed removed

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