-
Notifications
You must be signed in to change notification settings - Fork 208
Open
Labels
Description
Would be good to be able to pull the specific query that caused the error from the SQLException class. For example:
begin
ids = ids.join(",")
db.execute("SELECT * FROM table WHERE id IN(#{ids});")
rescue SQLite3::SQLException => e
log.error e.message # near ",": syntax error
# (WTF?)
log.debug e.query # SELECT * FROM table WHERE id IN(,1,2,3,4);
# (oh, right there's a nil entry in the array)
end
Gives some context to the particular SQL error that happened, assisting in troubleshooting code. I would submit a pull request, but I can't see in the code where I could set a attribute on the exception class (looks like it's done from C?).
Cheers