[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / class / Mono.Data.Sqlite / Mono.Data.Sqlite_2.0 / SQLiteException.cs
1 /********************************************************\r
2  * ADO.NET 2.0 Data Provider for SQLite Version 3.X\r
3  * Written by Robert Simpson (robert@blackcastlesoft.com)\r
4  * \r
5  * Released to the public domain, use at your own risk!\r
6  ********************************************************/\r
7 \r
8 namespace Mono.Data.Sqlite\r
9 {\r
10   using System;\r
11   using System.Collections.Generic;\r
12   using System.Text;\r
13   using System.Data.Common;\r
14 \r
15 #if !PLATFORM_COMPACTFRAMEWORK\r
16   using System.Runtime.Serialization;\r
17 #endif\r
18 \r
19   /// <summary>\r
20   /// SQLite exception class.\r
21   /// </summary>\r
22 #if !PLATFORM_COMPACTFRAMEWORK\r
23   [Serializable]\r
24   public sealed class SqliteException : DbException\r
25 #else\r
26   public sealed class SqliteException : Exception\r
27 #endif\r
28   {\r
29     private SQLiteErrorCode _errorCode;\r
30 \r
31 #if !PLATFORM_COMPACTFRAMEWORK\r
32     private SqliteException(SerializationInfo info, StreamingContext context)\r
33       : base(info, context)\r
34     {\r
35     }\r
36 #endif\r
37 \r
38     /// <summary>\r
39     /// Public constructor for generating a SQLite error given the base error code\r
40     /// </summary>\r
41     /// <param name="errorCode">The SQLite error code to report</param>\r
42     /// <param name="extendedInformation">Extra text to go along with the error message text</param>\r
43     public SqliteException(int errorCode, string extendedInformation)\r
44       : base(GetStockErrorMessage(errorCode, extendedInformation))\r
45     {\r
46       _errorCode = (SQLiteErrorCode)errorCode;\r
47     }\r
48 \r
49     /// <summary>\r
50     /// Various public constructors that just pass along to the base Exception\r
51     /// </summary>\r
52     /// <param name="message">Passed verbatim to Exception</param>\r
53     public SqliteException(string message)\r
54       : base(message)\r
55     {\r
56     }\r
57 \r
58     /// <summary>\r
59     /// Various public constructors that just pass along to the base Exception\r
60     /// </summary>\r
61     public SqliteException()\r
62     {\r
63     }\r
64 \r
65     /// <summary>\r
66     /// Various public constructors that just pass along to the base Exception\r
67     /// <param name="message">Passed to Exception</param>\r
68     /// <param name="innerException">Passed to Exception</param>\r
69     /// </summary>\r
70     public SqliteException(string message, Exception innerException)\r
71       : base(message, innerException)\r
72     {\r
73     }\r
74 \r
75     /// <summary>\r
76     /// Retrieves the underlying SQLite error code for this exception\r
77     /// </summary>\r
78 #if !PLATFORM_COMPACTFRAMEWORK\r
79     public new SQLiteErrorCode ErrorCode\r
80 #else\r
81     public SQLiteErrorCode ErrorCode\r
82 #endif\r
83     {\r
84       get { return _errorCode; }\r
85     }\r
86 \r
87     /// <summary>\r
88     /// Initializes the exception class with the SQLite error code.\r
89     /// </summary>\r
90     /// <param name="errorCode">The SQLite error code</param>\r
91     /// <param name="errorMessage">A detailed error message</param>\r
92     /// <returns>An error message string</returns>\r
93     private static string GetStockErrorMessage(int errorCode, string errorMessage)\r
94     {\r
95       if (errorMessage == null) errorMessage = "";\r
96 \r
97       if (errorMessage.Length > 0)\r
98         errorMessage = "\r\n" + errorMessage;\r
99 \r
100       if (errorCode < 0 || errorCode >= _errorMessages.Length)\r
101         errorCode = 1;\r
102 \r
103       return _errorMessages[errorCode] + errorMessage;\r
104     }\r
105 \r
106     private static string[] _errorMessages = {\r
107       "SQLite OK",\r
108       "SQLite error",\r
109       "An internal logic error in SQLite",\r
110       "Access permission denied",\r
111       "Callback routine requested an abort",\r
112       "The database file is locked",\r
113       "A table in the database is locked",\r
114       "malloc() failed",\r
115       "Attempt to write a read-only database",\r
116       "Operation terminated by sqlite3_interrupt()",\r
117       "Some kind of disk I/O error occurred",\r
118       "The database disk image is malformed",\r
119       "Table or record not found",\r
120       "Insertion failed because the database is full",\r
121       "Unable to open the database file",\r
122       "Database lock protocol error",\r
123       "Database is empty",\r
124       "The database schema changed",\r
125       "Too much data for one row of a table",\r
126       "Abort due to constraint violation",\r
127       "Data type mismatch",\r
128       "Library used incorrectly",\r
129       "Uses OS features not supported on host",\r
130       "Authorization denied",\r
131       "Auxiliary database format error",\r
132       "2nd parameter to sqlite3_bind() out of range",\r
133       "File opened that is not a database file",\r
134     };\r
135   }\r
136 \r
137   /// <summary>\r
138   /// SQLite error codes\r
139   /// </summary>\r
140   public enum SQLiteErrorCode\r
141   {\r
142     /// <summary>\r
143     /// Success\r
144     /// </summary>\r
145     Ok = 0,\r
146     /// <summary>\r
147     /// SQL error or missing database\r
148     /// </summary>\r
149     Error,\r
150     /// <summary>\r
151     /// Internal logic error in SQLite\r
152     /// </summary>\r
153     Internal,\r
154     /// <summary>\r
155     /// Access permission denied\r
156     /// </summary>\r
157     Perm,\r
158     /// <summary>\r
159     /// Callback routine requested an abort\r
160     /// </summary>\r
161     Abort,\r
162     /// <summary>\r
163     /// The database file is locked\r
164     /// </summary>\r
165     Busy,\r
166     /// <summary>\r
167     /// A table in the database is locked\r
168     /// </summary>\r
169     Locked,\r
170     /// <summary>\r
171     /// malloc() failed\r
172     /// </summary>\r
173     NoMem,\r
174     /// <summary>\r
175     /// Attempt to write a read-only database\r
176     /// </summary>\r
177     ReadOnly,\r
178     /// <summary>\r
179     /// Operation terminated by sqlite3_interrupt()\r
180     /// </summary>\r
181     Interrupt,\r
182     /// <summary>\r
183     /// Some kind of disk I/O error occurred\r
184     /// </summary>\r
185     IOErr,\r
186     /// <summary>\r
187     /// The database disk image is malformed\r
188     /// </summary>\r
189     Corrupt,\r
190     /// <summary>\r
191     /// Table or record not found\r
192     /// </summary>\r
193     NotFound,\r
194     /// <summary>\r
195     /// Insertion failed because database is full\r
196     /// </summary>\r
197     Full,\r
198     /// <summary>\r
199     /// Unable to open the database file\r
200     /// </summary>\r
201     CantOpen,\r
202     /// <summary>\r
203     /// Database lock protocol error\r
204     /// </summary>\r
205     Protocol,\r
206     /// <summary>\r
207     /// Database is empty\r
208     /// </summary>\r
209     Empty,\r
210     /// <summary>\r
211     /// The database schema changed\r
212     /// </summary>\r
213     Schema,\r
214     /// <summary>\r
215     /// Too much data for one row of a table\r
216     /// </summary>\r
217     TooBig,\r
218     /// <summary>\r
219     /// Abort due to constraint violation\r
220     /// </summary>\r
221     Constraint,\r
222     /// <summary>\r
223     /// Data type mismatch\r
224     /// </summary>\r
225     Mismatch,\r
226     /// <summary>\r
227     /// Library used incorrectly\r
228     /// </summary>\r
229     Misuse,\r
230     /// <summary>\r
231     /// Uses OS features not supported on host\r
232     /// </summary>\r
233     NOLFS,\r
234     /// <summary>\r
235     /// Authorization denied\r
236     /// </summary>\r
237     Auth,\r
238     /// <summary>\r
239     /// Auxiliary database format error\r
240     /// </summary>\r
241     Format,\r
242     /// <summary>\r
243     /// 2nd parameter to sqlite3_bind out of range\r
244     /// </summary>\r
245     Range,\r
246     /// <summary>\r
247     /// File opened that is not a database file\r
248     /// </summary>\r
249     NotADatabase,\r
250     /// <summary>\r
251     /// sqlite3_step() has another row ready\r
252     /// </summary>\r
253     Row = 100,\r
254     /// <summary>\r
255     /// sqlite3_step() has finished executing\r
256     /// </summary>\r
257     Done = 101,\r
258   }\r
259 }\r