private static RuntimeException getSqliteException(final String message, final int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
private void handleException(SQLException e) { if (e.getMessage().contains("No data is available")) { //if the query returns zero rows throw new SQLiteDoneException("No data is available"); } else if (e.getMessage().contains("ResultSet closed")) { //if the query returns zero rows (SQLiteMap) throw new SQLiteDoneException("ResultSet closed,(probably, no data available)"); } } }
private RuntimeException getSqliteException(String message, int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
private RuntimeException getSqliteException(String message, int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
private static RuntimeException getSqliteException(final String message, final int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
private static RuntimeException getSqliteException(final String message, final int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }