Detecting Database Errors
How Would I go about catching database Errors like "Locked" in sqlite3.
3 Answers
-
Accepted Answer
you should be able to wrap your database calls in a try/catch block. in the catch, you can try to parse out the error number from the exception message - e.g.,
try { // db calls } catch (e) { var message = e.message; // parse this to get the error }
here's a list of sqlite error codes:
http://www.sqlite.org/c3ref/c_abort.html
-
[Old topic but may help a lot of people]
Try catch is not working on databases. Check out the (tested and working!) answer of Simon Ferragne: http://developer.appcelerator.com/question/110201/how-to-trap-database-errors -
Robin,
It works for me. Don't forget that you will need <script></script> markers around your code.