bug 734624 - java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask.done(AsyncTask.java) caused by: android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed, catch potential exceptions r=mfinkle
authorBrad Lassey <blassey@mozilla.com>
Fri, 16 Mar 2012 12:21:04 -0400
changeset 89950 4e4076eb6524b1544fc8d94996e67668547af087
parent 89949 492b6530558f4e46c2d3ab0275f8ff9979a9ce5f
child 89951 3b06cfee48cdce15fe6936f2223e7cb078b92280
push id22300
push usermak77@bonardo.net
push dateThu, 22 Mar 2012 12:08:29 +0000
treeherdermozilla-central@b622d692b8ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs734624
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 734624 - java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask.done(AsyncTask.java) caused by: android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed, catch potential exceptions r=mfinkle
mobile/android/base/db/BrowserProvider.java.in
--- a/mobile/android/base/db/BrowserProvider.java.in
+++ b/mobile/android/base/db/BrowserProvider.java.in
@@ -912,29 +912,34 @@ public class BrowserProvider extends Con
     }
 
     @Override
     public Uri insert(Uri uri, ContentValues values) {
         trace("Calling insert on URI: " + uri);
 
         final SQLiteDatabase db = getWritableDatabase(uri);
         Uri result = null;
-
-        if (Build.VERSION.SDK_INT >= 11) {
-            trace("Beginning insert transaction: " + uri);
-            db.beginTransaction();
-            try {
+        try {
+            if (Build.VERSION.SDK_INT >= 11) {
+                trace("Beginning insert transaction: " + uri);
+                db.beginTransaction();
+                try {
+                    result = insertInTransaction(uri, values);
+                    db.setTransactionSuccessful();
+                    trace("Successful insert transaction: " + uri);
+                } finally {
+                    db.endTransaction();
+                }
+            } else {
                 result = insertInTransaction(uri, values);
-                db.setTransactionSuccessful();
-                trace("Successful insert transaction: " + uri);
-            } finally {
-                db.endTransaction();
             }
-        } else {
-            result = insertInTransaction(uri, values);
+        } catch (SQLException sqle) {
+            Log.e(LOGTAG, "exception in DB operation", sqle);
+        } catch (UnsupportedOperationException uoe) {
+            Log.e(LOGTAG, "don't know how to perform that insert", uoe);
         }
 
         if (result != null)
             getContext().getContentResolver().notifyChange(uri, null);
 
         return result;
     }