improved SQLite error handling