diff options
author | Vasu Nori <vnori@google.com> | 2010-07-28 18:23:33 -0700 |
---|---|---|
committer | Vasu Nori <vnori@google.com> | 2010-07-29 14:57:08 -0700 |
commit | dea9713387460c560b67106ab913f686f7d16af2 (patch) | |
tree | 93f50c4702a90e035ed485c59475d0c2fb99e886 /core | |
parent | f82447e43e87c288c3bb41cdb0474a3204c2bd0d (diff) | |
download | frameworks_base-dea9713387460c560b67106ab913f686f7d16af2.zip frameworks_base-dea9713387460c560b67106ab913f686f7d16af2.tar.gz frameworks_base-dea9713387460c560b67106ab913f686f7d16af2.tar.bz2 |
expose more sqlite errors as exceptions
this should help developers figure out what various sqlite errors mean
and possibly programmatically handle them.
Change-Id: I5c313be1b17b6c5171929bf04e19a16ea92bb357
Diffstat (limited to 'core')
10 files changed, 267 insertions, 0 deletions
diff --git a/core/java/android/database/sqlite/SQLiteAccessPermException.java b/core/java/android/database/sqlite/SQLiteAccessPermException.java new file mode 100644 index 0000000..238da4b --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteAccessPermException.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +/** + * This exception class is used when sqlite can't access the database file + * due to lack of permissions on the file. + */ +public class SQLiteAccessPermException extends SQLiteException { + public SQLiteAccessPermException() {} + + public SQLiteAccessPermException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteBindOrColumnIndexOutOfRangeException.java b/core/java/android/database/sqlite/SQLiteBindOrColumnIndexOutOfRangeException.java new file mode 100644 index 0000000..41f2f9c --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteBindOrColumnIndexOutOfRangeException.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +/** + * Thrown if the the bind or column parameter index is out of range + */ +public class SQLiteBindOrColumnIndexOutOfRangeException extends SQLiteException { + public SQLiteBindOrColumnIndexOutOfRangeException() {} + + public SQLiteBindOrColumnIndexOutOfRangeException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteBlobTooBigException.java b/core/java/android/database/sqlite/SQLiteBlobTooBigException.java new file mode 100644 index 0000000..a82676b --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteBlobTooBigException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +public class SQLiteBlobTooBigException extends SQLiteException { + public SQLiteBlobTooBigException() {} + + public SQLiteBlobTooBigException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteCantOpenDatabaseException.java b/core/java/android/database/sqlite/SQLiteCantOpenDatabaseException.java new file mode 100644 index 0000000..6f01796 --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteCantOpenDatabaseException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +public class SQLiteCantOpenDatabaseException extends SQLiteException { + public SQLiteCantOpenDatabaseException() {} + + public SQLiteCantOpenDatabaseException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteDatabaseLockedException.java b/core/java/android/database/sqlite/SQLiteDatabaseLockedException.java new file mode 100644 index 0000000..f0e2d81 --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteDatabaseLockedException.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +/** + * Thrown if the database engine was unable to acquire the + * database locks it needs to do its job. If the statement is a [COMMIT] + * or occurs outside of an explicit transaction, then you can retry the + * statement. If the statement is not a [COMMIT] and occurs within a + * explicit transaction then you should rollback the transaction before + * continuing. + */ +public class SQLiteDatabaseLockedException extends SQLiteException { + public SQLiteDatabaseLockedException() {} + + public SQLiteDatabaseLockedException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteDatatypeMismatchException.java b/core/java/android/database/sqlite/SQLiteDatatypeMismatchException.java new file mode 100644 index 0000000..7f82535 --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteDatatypeMismatchException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +public class SQLiteDatatypeMismatchException extends SQLiteException { + public SQLiteDatatypeMismatchException() {} + + public SQLiteDatatypeMismatchException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteOutOfMemoryException.java b/core/java/android/database/sqlite/SQLiteOutOfMemoryException.java new file mode 100644 index 0000000..98ce8b5 --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteOutOfMemoryException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +public class SQLiteOutOfMemoryException extends SQLiteException { + public SQLiteOutOfMemoryException() {} + + public SQLiteOutOfMemoryException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteReadOnlyDatabaseException.java b/core/java/android/database/sqlite/SQLiteReadOnlyDatabaseException.java new file mode 100644 index 0000000..5b633c6 --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteReadOnlyDatabaseException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +public class SQLiteReadOnlyDatabaseException extends SQLiteException { + public SQLiteReadOnlyDatabaseException() {} + + public SQLiteReadOnlyDatabaseException(String error) { + super(error); + } +} diff --git a/core/java/android/database/sqlite/SQLiteTableLockedException.java b/core/java/android/database/sqlite/SQLiteTableLockedException.java new file mode 100644 index 0000000..8278df0 --- /dev/null +++ b/core/java/android/database/sqlite/SQLiteTableLockedException.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +public class SQLiteTableLockedException extends SQLiteException { + public SQLiteTableLockedException() {} + + public SQLiteTableLockedException(String error) { + super(error); + } +} diff --git a/core/jni/android_database_SQLiteDatabase.cpp b/core/jni/android_database_SQLiteDatabase.cpp index 003bbc1..45d2e1e 100644 --- a/core/jni/android_database_SQLiteDatabase.cpp +++ b/core/jni/android_database_SQLiteDatabase.cpp @@ -556,6 +556,33 @@ void throw_sqlite3_exception(JNIEnv* env, int errcode, case SQLITE_MISUSE: exceptionClass = "android/database/sqlite/SQLiteMisuseException"; break; + case SQLITE_PERM: + exceptionClass = "android/database/sqlite/SQLiteAccessPermException"; + break; + case SQLITE_BUSY: + exceptionClass = "android/database/sqlite/SQLiteDatabaseLockedException"; + break; + case SQLITE_LOCKED: + exceptionClass = "android/database/sqlite/SQLiteTableLockedException"; + break; + case SQLITE_READONLY: + exceptionClass = "android/database/sqlite/SQLiteReadOnlyDatabaseException"; + break; + case SQLITE_CANTOPEN: + exceptionClass = "android/database/sqlite/SQLiteCantOpenDatabaseException"; + break; + case SQLITE_TOOBIG: + exceptionClass = "android/database/sqlite/SQLiteBlobTooBigException"; + break; + case SQLITE_RANGE: + exceptionClass = "android/database/sqlite/SQLiteBindOrColumnIndexOutOfRangeException"; + break; + case SQLITE_NOMEM: + exceptionClass = "android/database/sqlite/SQLiteOutOfMemoryException"; + break; + case SQLITE_MISMATCH: + exceptionClass = "android/database/sqlite/SQLiteDatatypeMismatchException"; + break; default: exceptionClass = "android/database/sqlite/SQLiteException"; break; |