Bugs: Browse | Submit New | Admin

[#5504] [PATCH] Fix: SQLite3::Database.new throws away error details

Date:
2006-08-24 05:08
Priority:
3
Submitted By:
Tom Moertel (tmoertel)
Assigned To:
Jamis Buck (minam)
Category:
None
State:
Closed
Summary:
[PATCH] Fix: SQLite3::Database.new throws away error details

Detailed description
When SQLite3::Database.new fails to establish a database connection, the resulting exception does not report the underlying
cause.  For example:

  $ ruby -r sqlite3 -e 'SQLite3::Database.new("/no/such/path/db")'

The result is a generic exception:

  could not open database (SQLite3::CantOpenException)

In this case, the underlying cause that the SQLite3 library reports is "unable to open database file".  This
information, however, is never requested by the Ruby wrapper because the connection handle (which SQLite3 returns even
if sqlite3_open() fails) is not passed through to the wrapper's generic Error.check routine.

Enclosed is a tiny patch that fixes the problem.  After applying it, we get the full details of the failure:

  could not open database: unable to open database file (SQLite3::CantOpenException)


Cheers,
Tom Moertel <tom@moertel.com>

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-01-13 20:10
Sender: Jamis Buck

Applied, thanks!

Attached Files:

Name Description Download
detailed-errors-for-connection-failures.diff Patch that provides for detailed error reporting when SQLite3::Database.new fails to establish a database connection Download

Changes:

Field Old Value Date By
status_idOpen2007-01-13 20:11minam
resolution_idNone2007-01-13 20:11minam
assigned_tonone2007-01-13 20:11minam
close_date2007-01-13 20:112007-01-13 20:11minam
File Added767: detailed-errors-for-connection-failures.diff2006-08-24 05:08tmoertel