[TIMOB-1666] Attempting to SELECT from a non-existant table crashes the app
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-06-28T10:45:54.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Sprint 2011-26, Release 1.7.2 |
Components | iOS |
Labels | database, error, exception, handling, ios |
Reporter | ben (at galbraiths) |
Assignee | Stephen Tramer |
Created | 2011-04-15T02:58:51.000+0000 |
Updated | 2011-10-27T17:57:54.000+0000 |
Description
I have this code:
try {
var rs = db.execute('SELECT * FROM meta');
} catch (e) {
Ti.API.info("Error: " + e);
}
which results in my app crashing with this error in the OS X Console:
8/28/10 4:15:45 PM BillingWorks3[17336] *** Terminating app due to uncaught exception 'org.billingworks3.TiDatabaseProxy', reason: 'invalid SQL statement. Error Domain=com.plausiblelabs.pldatabase Code=3 "An error occured parsing the provided SQL statement." UserInfo=0x911bcf0 {com.plausiblelabs.pldatabase.error.vendor.code=1, NSLocalizedDescription=An error occured parsing the provided SQL statement., com.plausiblelabs.pldatabase.error.query.string=SELECT * FROM meta, com.plausiblelabs.pldatabase.error.vendor.string=no such table: meta} in -[TiDatabaseProxy execute:] (TiDatabaseProxy.m:134)'
I would have expected my error handler to have caught the exception rather than crashing the app.
Attachments
File | Date | Size |
---|---|---|
test.js | 2011-06-27T05:54:47.000+0000 | 41358 |
We need to have a Serious Discussion about error handling.
I reported this in June last year, and it doesn't seem to be specific to DB errors. The helpdesk ticket is http://developer.appcelerator.com/helpdesk/view/19401">http://developer.appcelerator.com/helpdesk/view/19401. I thought the problem went away at one point, but crashing due to bad DB calls appears to be back in 1.5.1.
Sorry, to clarify, I can confirm it's broken in 1.5.1. I don't know when it broke.
Crash happens on simulator according to the crash log. May be resolved by the other linked issue.
Replace the test.js from the TIMOB-4174 resources with this test.js to gain the 'SELECT * FROM nonexist' test.
After compiling and running on device, view console and search for "passed":false if string is not found, the test passed
Combined test app from 4174 with test.js from this test and ran on iPhone 4. all "Passed": log entries are true. Verified with SDKs 1.7.2 r3d44999e and 1.8.0 r4b694252.