I'm having trouble finding out, for the Sqlite.Net data provider (System.Data.Sqlite.dll) (new development has forked here), what exceptions are thrown by the various classes and their methods. I know there are SqliteExceptions that can be thrown, but when?
I have ensured I have the accompanying System.Data.Sqlite.xml documentation file, but it doesn't appear to list what exceptions are thrown by each method.
I don't want to wrap unnecessary code into try/catch blocks (or blindly catch a generic Exception everywhere).
I know that SqliteConnection is derived from DbConnection, and SqliteCommand is derived from DbCommand, so if necessary I guess I can look at the documentation there. However, none of the base classes will list SqliteException, so when will those type of exceptions be thrown?
P开发者_运维百科S - I'm using version 1.0.64 (from 2009... can't upgrade at this time).
UPDATE:
Due to the lack of responses, is there anyone out there that uses System.Data.Sqlite.dll? If so, what approach do you take to handle exceptions that may be thrown from the objects available in the library? Is there some standard way to deal with these exceptions since it seems there is no documentation on the exceptions that are thrown and by which classes?
UPDATE 2:
I did manage to find the SQLite.NET documentation found under c:\program files\SQLite.NET\Doc\ (seems kind of obvious). Great documentation so far, however it doesn't tell you what exceptions are thrown. The best I can do so far is to look at the base classes that are inherited or interfaces that are implemented and see what exceptions are thrown. This still doesn't help in knowing when an SqliteException object is thrown though.
UPDATE 3:
After getting a hold of the source code, it appears that none of the classes themselves contain any /// <exception cref="ExceptionType">Something went wrong!</exception>
xml comments. This explains why neither the SQLite.NET help file or Visual Studio Intellisense is listing any exceptions that may be thrown. I've created a ticket requesting the xml comments to include the exceptions, offering to add them myself if it is too low on their priority list. I'll keep this question updated with any new developments for anyone who might be interested.
you could use the "brute" way searching into code or by reflector for Exception.
Es: reflector --> analyze "System.Data.SQLite.SQLiteException" --> Instantiated By
System.Data.SQLite.SQLite3.Bind_Blob(SQLiteStatement, Int32, Byte[]) : Void
System.Data.SQLite.SQLite3.Bind_DateTime(SQLiteStatement, Int32, DateTime) : Void
System.Data.SQLite.SQLite3.Bind_Double(SQLiteStatement, Int32, Double) : Void
System.Data.SQLite.SQLite3.Bind_Int32(SQLiteStatement, Int32, Int32) : Void
System.Data.SQLite.SQLite3.Bind_Int64(SQLiteStatement, Int32, Int64) : Void
System.Data.SQLite.SQLite3.Bind_Null(SQLiteStatement, Int32) : Void
System.Data.SQLite.SQLite3.Bind_Text(SQLiteStatement, Int32, String) : Void
System.Data.SQLite.SQLite3.ChangePassword(Byte[]) : Void
System.Data.SQLite.SQLite3.ColumnMetaData(String, String, String, String&, String&, Boolean&, Boolean&, Boolean&) : Void
System.Data.SQLite.SQLite3.CreateCollation(String, SQLiteCollation, SQLiteCollation) : Void
System.Data.SQLite.SQLite3.CreateFunction(String, Int32, Boolean, SQLiteCallback, SQLiteCallback, SQLiteFinalCallback) : Void
System.Data.SQLite.SQLite3.GetIndexColumnExtendedInfo(String, String, String, Int32&, Int32&, String&) : Void
System.Data.SQLite.SQLite3.Open(String, SQLiteOpenFlagsEnum, Int32, Boolean) : Void
System.Data.SQLite.SQLite3.Prepare(SQLiteConnection, String, SQLiteStatement, UInt32, String&) : SQLiteStatement
System.Data.SQLite.SQLite3.Reset(SQLiteStatement) : Int32
System.Data.SQLite.SQLite3.SetPassword(Byte[]) : Void
System.Data.SQLite.SQLite3.SetTimeout(Int32) : Void
System.Data.SQLite.SQLite3.Step(SQLiteStatement) : Boolean
System.Data.SQLite.SQLite3_UTF16.Bind_Text(SQLiteStatement, Int32, String) : Void
System.Data.SQLite.SQLite3_UTF16.Open(String, SQLiteOpenFlagsEnum, Int32, Boolean) : Void
System.Data.SQLite.SQLiteBase.CloseConnection(SQLiteConnectionHandle) : Void
System.Data.SQLite.SQLiteBase.FinalizeStatement(SQLiteStatementHandle) : Void
System.Data.SQLite.SQLiteBase.ResetConnection(SQLiteConnectionHandle) : Void
System.Data.SQLite.SQLiteDataReader.CheckClosed() : Void
System.Data.SQLite.SQLiteStatement.BindParameter(Int32, SQLiteParameter) : Void
System.Data.SQLite.SQLiteTransaction.IsValid(Boolean) : Boolean
精彩评论