Index: System.Data.SQLite/SQLiteException.cs
==================================================================
--- System.Data.SQLite/SQLiteException.cs
+++ System.Data.SQLite/SQLiteException.cs
@@ -1,119 +1,119 @@
-/********************************************************
- * ADO.NET 2.0 Data Provider for SQLite Version 3.X
- * Written by Robert Simpson (robert@blackcastlesoft.com)
- *
- * Released to the public domain, use at your own risk!
- ********************************************************/
-
-namespace System.Data.SQLite
-{
+/********************************************************
+ * ADO.NET 2.0 Data Provider for SQLite Version 3.X
+ * Written by Robert Simpson (robert@blackcastlesoft.com)
+ *
+ * Released to the public domain, use at your own risk!
+ ********************************************************/
+
+namespace System.Data.SQLite
+{
using System;
- using System.Data.Common;
-
-#if !PLATFORM_COMPACTFRAMEWORK
- using System.Reflection;
- using System.Runtime.Serialization;
+ using System.Data.Common;
+
+#if !PLATFORM_COMPACTFRAMEWORK
+ using System.Reflection;
+ using System.Runtime.Serialization;
using System.Security.Permissions;
-#endif
-
- ///
- /// SQLite exception class.
- ///
-#if !PLATFORM_COMPACTFRAMEWORK
- [Serializable()]
- public sealed class SQLiteException : DbException, ISerializable
-#else
- public sealed class SQLiteException : Exception
-#endif
- {
- private SQLiteErrorCode _errorCode;
-
-#if !PLATFORM_COMPACTFRAMEWORK
- ///
- /// Private constructor for use with serialization.
- ///
- ///
- /// Holds the serialized object data about the exception being thrown.
- ///
- ///
- /// Contains contextual information about the source or destination.
- ///
- private SQLiteException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- _errorCode = (SQLiteErrorCode)info.GetInt32("errorCode");
- }
-#endif
-
- ///
- /// Public constructor for generating a SQLite exception given the error
- /// code and message.
- ///
- ///
- /// The SQLite return code to report.
- ///
- ///
- /// Message text to go along with the return code message text.
- ///
- public SQLiteException(SQLiteErrorCode errorCode, string message)
- : base(GetStockErrorMessage(errorCode, message))
- {
- _errorCode = errorCode;
- }
-
- ///
- /// Public constructor that uses the base class constructor for the error
- /// message.
- ///
- /// Error message text.
- public SQLiteException(string message)
- : base(message)
- {
- }
-
- ///
- /// Public constructor that uses the default base class constructor.
- ///
- public SQLiteException()
- {
- }
-
- ///
- /// Public constructor that uses the base class constructor for the error
- /// message and inner exception.
- ///
- /// Error message text.
- /// The original (inner) exception.
- public SQLiteException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
-
-#if !PLATFORM_COMPACTFRAMEWORK
- ///
- /// Adds extra information to the serialized object data specific to this
- /// class type. This is only used for serialization.
- ///
- ///
- /// Holds the serialized object data about the exception being thrown.
- ///
- ///
- /// Contains contextual information about the source or destination.
- ///
- [SecurityPermission(
- SecurityAction.LinkDemand,
- Flags = SecurityPermissionFlag.SerializationFormatter)]
- public override void GetObjectData(
- SerializationInfo info,
- StreamingContext context)
- {
- if (info != null)
- info.AddValue("errorCode", _errorCode);
-
- base.GetObjectData(info, context);
- }
+#endif
+
+ ///
+ /// SQLite exception class.
+ ///
+#if !PLATFORM_COMPACTFRAMEWORK
+ [Serializable()]
+ public sealed class SQLiteException : DbException, ISerializable
+#else
+ public sealed class SQLiteException : Exception
+#endif
+ {
+ private SQLiteErrorCode _errorCode;
+
+#if !PLATFORM_COMPACTFRAMEWORK
+ ///
+ /// Private constructor for use with serialization.
+ ///
+ ///
+ /// Holds the serialized object data about the exception being thrown.
+ ///
+ ///
+ /// Contains contextual information about the source or destination.
+ ///
+ private SQLiteException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ _errorCode = (SQLiteErrorCode)info.GetInt32("errorCode");
+ }
+#endif
+
+ ///
+ /// Public constructor for generating a SQLite exception given the error
+ /// code and message.
+ ///
+ ///
+ /// The SQLite return code to report.
+ ///
+ ///
+ /// Message text to go along with the return code message text.
+ ///
+ public SQLiteException(SQLiteErrorCode errorCode, string message)
+ : base(GetStockErrorMessage(errorCode, message))
+ {
+ _errorCode = errorCode;
+ }
+
+ ///
+ /// Public constructor that uses the base class constructor for the error
+ /// message.
+ ///
+ /// Error message text.
+ public SQLiteException(string message)
+ : base(message)
+ {
+ }
+
+ ///
+ /// Public constructor that uses the default base class constructor.
+ ///
+ public SQLiteException()
+ {
+ }
+
+ ///
+ /// Public constructor that uses the base class constructor for the error
+ /// message and inner exception.
+ ///
+ /// Error message text.
+ /// The original (inner) exception.
+ public SQLiteException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
+#if !PLATFORM_COMPACTFRAMEWORK
+ ///
+ /// Adds extra information to the serialized object data specific to this
+ /// class type. This is only used for serialization.
+ ///
+ ///
+ /// Holds the serialized object data about the exception being thrown.
+ ///
+ ///
+ /// Contains contextual information about the source or destination.
+ ///
+ [SecurityPermission(
+ SecurityAction.LinkDemand,
+ Flags = SecurityPermissionFlag.SerializationFormatter)]
+ public override void GetObjectData(
+ SerializationInfo info,
+ StreamingContext context)
+ {
+ if (info != null)
+ info.AddValue("errorCode", _errorCode);
+
+ base.GetObjectData(info, context);
+ }
#endif
///
/// Gets the associated SQLite return code for this exception as a
/// . This property returns the same
@@ -121,196 +121,200 @@
///
public SQLiteErrorCode ReturnCode
{
get { return _errorCode; }
}
-
+
///
- /// Gets the associated SQLite return code for this exception as an
+ /// Gets the associated SQLite return code for this exception as an
/// . For desktop versions of the .NET Framework,
- /// this property overrides the property of the same name within the
- ///
+ /// this property overrides the property of the same name within the
+ ///
/// class. This property returns the same underlying value as the
- /// property.
- ///
-#if !PLATFORM_COMPACTFRAMEWORK
- public override int ErrorCode
-#else
- public int ErrorCode
-#endif
- {
- get { return (int)_errorCode; }
- }
-
- ///
- /// Returns the error message for the specified SQLite return code.
- ///
- /// The SQLite return code.
- /// The error message or null if it cannot be found.
- private static string GetErrorString(
- SQLiteErrorCode errorCode
- )
- {
-#if !PLATFORM_COMPACTFRAMEWORK
- //
- // HACK: This must be done via reflection in order to prevent
- // the RuntimeHelpers.PrepareDelegate method from over-
- // eagerly attempting to locate the new (and optional)
- // sqlite3_errstr() function in the SQLite core library
- // because it happens to be in the static call graph for
- // the AppDomain.DomainUnload event handler registered
- // by the SQLiteLog class.
- //
- BindingFlags flags = BindingFlags.Static |
- BindingFlags.NonPublic | BindingFlags.InvokeMethod;
-
- return typeof(SQLiteBase).InvokeMember("GetErrorString",
- flags, null, null, new object[] { errorCode }) as string;
-#else
- return SQLiteBase.GetErrorString(errorCode);
-#endif
- }
-
- ///
- /// Returns the composite error message based on the SQLite return code
- /// and the optional detailed error message.
- ///
- /// The SQLite return code.
- /// Optional detailed error message.
- /// Error message text for the return code.
- private static string GetStockErrorMessage(
- SQLiteErrorCode errorCode,
- string message
- )
- {
- return String.Format("{0}{1}{2}",
- GetErrorString(errorCode),
- Environment.NewLine, message).Trim();
- }
- }
-
- ///
- /// SQLite error codes. Actually, this enumeration represents a return code,
- /// which may also indicate success in one of several ways (e.g. SQLITE_OK,
- /// SQLITE_ROW, and SQLITE_DONE). Therefore, the name of this enumeration is
- /// something of a misnomer.
- ///
- public enum SQLiteErrorCode
- {
- ///
- /// Successful result
- ///
- Ok /* 0 */,
- ///
- /// SQL error or missing database
- ///
- Error /* 1 */,
- ///
- /// Internal logic error in SQLite
- ///
- Internal /* 2 */,
- ///
- /// Access permission denied
- ///
- Perm /* 3 */,
- ///
- /// Callback routine requested an abort
- ///
- Abort /* 4 */,
- ///
- /// The database file is locked
- ///
- Busy /* 5 */,
- ///
- /// A table in the database is locked
- ///
- Locked /* 6 */,
- ///
- /// A malloc() failed
- ///
- NoMem /* 7 */,
- ///
- /// Attempt to write a readonly database
- ///
- ReadOnly /* 8 */,
- ///
- /// Operation terminated by sqlite3_interrupt()
- ///
- Interrupt /* 9 */,
- ///
- /// Some kind of disk I/O error occurred
- ///
- IoErr /* 10 */,
- ///
- /// The database disk image is malformed
- ///
- Corrupt /* 11 */,
- ///
- /// Unknown opcode in sqlite3_file_control()
- ///
- NotFound /* 12 */,
- ///
- /// Insertion failed because database is full
- ///
- Full /* 13 */,
- ///
- /// Unable to open the database file
- ///
- CantOpen /* 14 */,
- ///
- /// Database lock protocol error
- ///
- Protocol /* 15 */,
- ///
- /// Database is empty
- ///
- Empty /* 16 */,
- ///
- /// The database schema changed
- ///
- Schema /* 17 */,
- ///
- /// String or BLOB exceeds size limit
- ///
- TooBig /* 18 */,
- ///
- /// Abort due to constraint violation
- ///
- Constraint /* 19 */,
- ///
- /// Data type mismatch
- ///
- Mismatch /* 20 */,
- ///
- /// Library used incorrectly
- ///
- Misuse /* 21 */,
- ///
- /// Uses OS features not supported on host
- ///
- NoLfs /* 22 */,
- ///
- /// Authorization denied
- ///
- Auth /* 23 */,
- ///
- /// Auxiliary database format error
- ///
- Format /* 24 */,
- ///
- /// 2nd parameter to sqlite3_bind out of range
- ///
- Range /* 25 */,
- ///
- /// File opened that is not a database file
- ///
- NotADb /* 26 */,
- ///
- /// sqlite3_step() has another row ready
- ///
- Row = 100,
- ///
- /// sqlite3_step() has finished executing
- ///
- Done /* 101 */
- }
-}
+ /// property.
+ ///
+#if !PLATFORM_COMPACTFRAMEWORK
+ public override int ErrorCode
+#else
+ public int ErrorCode
+#endif
+ {
+ get { return (int)_errorCode; }
+ }
+
+ ///
+ /// Returns the error message for the specified SQLite return code.
+ ///
+ /// The SQLite return code.
+ /// The error message or null if it cannot be found.
+ private static string GetErrorString(
+ SQLiteErrorCode errorCode
+ )
+ {
+#if !PLATFORM_COMPACTFRAMEWORK
+ //
+ // HACK: This must be done via reflection in order to prevent
+ // the RuntimeHelpers.PrepareDelegate method from over-
+ // eagerly attempting to locate the new (and optional)
+ // sqlite3_errstr() function in the SQLite core library
+ // because it happens to be in the static call graph for
+ // the AppDomain.DomainUnload event handler registered
+ // by the SQLiteLog class.
+ //
+ BindingFlags flags = BindingFlags.Static |
+ BindingFlags.NonPublic | BindingFlags.InvokeMethod;
+
+ return typeof(SQLiteBase).InvokeMember("GetErrorString",
+ flags, null, null, new object[] { errorCode }) as string;
+#else
+ return SQLiteBase.GetErrorString(errorCode);
+#endif
+ }
+
+ ///
+ /// Returns the composite error message based on the SQLite return code
+ /// and the optional detailed error message.
+ ///
+ /// The SQLite return code.
+ /// Optional detailed error message.
+ /// Error message text for the return code.
+ private static string GetStockErrorMessage(
+ SQLiteErrorCode errorCode,
+ string message
+ )
+ {
+ return String.Format("{0}{1}{2}",
+ GetErrorString(errorCode),
+#if !NET_COMPACT_20
+ Environment.NewLine, message).Trim();
+#else
+ "\r\n", message).Trim();
+#endif
+ }
+ }
+
+ ///
+ /// SQLite error codes. Actually, this enumeration represents a return code,
+ /// which may also indicate success in one of several ways (e.g. SQLITE_OK,
+ /// SQLITE_ROW, and SQLITE_DONE). Therefore, the name of this enumeration is
+ /// something of a misnomer.
+ ///
+ public enum SQLiteErrorCode
+ {
+ ///
+ /// Successful result
+ ///
+ Ok /* 0 */,
+ ///
+ /// SQL error or missing database
+ ///
+ Error /* 1 */,
+ ///
+ /// Internal logic error in SQLite
+ ///
+ Internal /* 2 */,
+ ///
+ /// Access permission denied
+ ///
+ Perm /* 3 */,
+ ///
+ /// Callback routine requested an abort
+ ///
+ Abort /* 4 */,
+ ///
+ /// The database file is locked
+ ///
+ Busy /* 5 */,
+ ///
+ /// A table in the database is locked
+ ///
+ Locked /* 6 */,
+ ///
+ /// A malloc() failed
+ ///
+ NoMem /* 7 */,
+ ///
+ /// Attempt to write a readonly database
+ ///
+ ReadOnly /* 8 */,
+ ///
+ /// Operation terminated by sqlite3_interrupt()
+ ///
+ Interrupt /* 9 */,
+ ///
+ /// Some kind of disk I/O error occurred
+ ///
+ IoErr /* 10 */,
+ ///
+ /// The database disk image is malformed
+ ///
+ Corrupt /* 11 */,
+ ///
+ /// Unknown opcode in sqlite3_file_control()
+ ///
+ NotFound /* 12 */,
+ ///
+ /// Insertion failed because database is full
+ ///
+ Full /* 13 */,
+ ///
+ /// Unable to open the database file
+ ///
+ CantOpen /* 14 */,
+ ///
+ /// Database lock protocol error
+ ///
+ Protocol /* 15 */,
+ ///
+ /// Database is empty
+ ///
+ Empty /* 16 */,
+ ///
+ /// The database schema changed
+ ///
+ Schema /* 17 */,
+ ///
+ /// String or BLOB exceeds size limit
+ ///
+ TooBig /* 18 */,
+ ///
+ /// Abort due to constraint violation
+ ///
+ Constraint /* 19 */,
+ ///
+ /// Data type mismatch
+ ///
+ Mismatch /* 20 */,
+ ///
+ /// Library used incorrectly
+ ///
+ Misuse /* 21 */,
+ ///
+ /// Uses OS features not supported on host
+ ///
+ NoLfs /* 22 */,
+ ///
+ /// Authorization denied
+ ///
+ Auth /* 23 */,
+ ///
+ /// Auxiliary database format error
+ ///
+ Format /* 24 */,
+ ///
+ /// 2nd parameter to sqlite3_bind out of range
+ ///
+ Range /* 25 */,
+ ///
+ /// File opened that is not a database file
+ ///
+ NotADb /* 26 */,
+ ///
+ /// sqlite3_step() has another row ready
+ ///
+ Row = 100,
+ ///
+ /// sqlite3_step() has finished executing
+ ///
+ Done /* 101 */
+ }
+}