Bug 837379 - Log better exception messages in GeckoEditable; r=cpeterson
authorJim Chen <nchen@mozilla.com>
Mon, 10 Jun 2013 10:15:41 -0400
changeset 134519 21800605ea673bfb355020c43b81a284a44ab9c4
parent 134518 af580d8db2102503856044f4574c0b30b5f72003
child 134520 1c4403cbda5732fb4f18be1ea28059ea23e5617c
push id24803
push userryanvm@gmail.com
push dateMon, 10 Jun 2013 19:43:46 +0000
treeherdermozilla-central@9115d8b717e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs837379
milestone24.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 837379 - Log better exception messages in GeckoEditable; r=cpeterson
mobile/android/base/GeckoEditable.java
--- a/mobile/android/base/GeckoEditable.java
+++ b/mobile/android/base/GeckoEditable.java
@@ -136,40 +136,43 @@ final class GeckoEditable
         Handler mHandler;
 
         Action(int type) {
             mType = type;
         }
 
         static Action newReplaceText(CharSequence text, int start, int end) {
             if (start < 0 || start > end) {
-                throw new IllegalArgumentException("invalid replace text offsets");
+                throw new IllegalArgumentException(
+                    "invalid replace text offsets: " + start + " to " + end);
             }
             final Action action = new Action(TYPE_REPLACE_TEXT);
             action.mSequence = text;
             action.mStart = start;
             action.mEnd = end;
             return action;
         }
 
         static Action newSetSelection(int start, int end) {
             // start == -1 when the start offset should remain the same
             // end == -1 when the end offset should remain the same
             if (start < -1 || end < -1) {
-                throw new IllegalArgumentException("invalid selection offsets");
+                throw new IllegalArgumentException(
+                    "invalid selection offsets: " + start + " to " + end);
             }
             final Action action = new Action(TYPE_SET_SELECTION);
             action.mStart = start;
             action.mEnd = end;
             return action;
         }
 
         static Action newSetSpan(Object object, int start, int end, int flags) {
             if (start < 0 || start > end) {
-                throw new IllegalArgumentException("invalid span offsets");
+                throw new IllegalArgumentException(
+                    "invalid span offsets: " + start + " to " + end);
             }
             final Action action = new Action(TYPE_SET_SPAN);
             action.mSpanObject = object;
             action.mStart = start;
             action.mEnd = end;
             action.mSpanFlags = flags;
             return action;
         }
@@ -788,17 +791,18 @@ final class GeckoEditable
     @Override
     public void onSelectionChange(final int start, final int end) {
         if (DEBUG) {
             // GeckoEditableListener methods should all be called from the Gecko thread
             ThreadUtils.assertOnGeckoThread();
             Log.d(LOGTAG, "onSelectionChange(" + start + ", " + end + ")");
         }
         if (start < 0 || start > mText.length() || end < 0 || end > mText.length()) {
-            throw new IllegalArgumentException("invalid selection notification range");
+            throw new IllegalArgumentException("invalid selection notification range: " +
+                start + " to " + end + ", length: " + mText.length());
         }
         final int seqnoWhenPosted = ++mGeckoUpdateSeqno;
 
         /* An event (keypress, etc.) has potentially changed the selection,
            synchronize the selection here. There is not a race with the IC thread
            because the IC thread should be blocked on the event action */
         if (!mActionQueue.isEmpty() &&
             mActionQueue.peek().mType == Action.TYPE_EVENT) {
@@ -839,24 +843,26 @@ final class GeckoEditable
                       final int unboundedOldEnd, final int unboundedNewEnd) {
         if (DEBUG) {
             // GeckoEditableListener methods should all be called from the Gecko thread
             ThreadUtils.assertOnGeckoThread();
             Log.d(LOGTAG, "onTextChange(\"" + text + "\", " + start + ", " +
                           unboundedOldEnd + ", " + unboundedNewEnd + ")");
         }
         if (start < 0 || start > unboundedOldEnd) {
-            throw new IllegalArgumentException("invalid text notification range");
+            throw new IllegalArgumentException("invalid text notification range: " +
+                start + " to " + unboundedOldEnd);
         }
         /* For the "end" parameters, Gecko can pass in a large
            number to denote "end of the text". Fix that here */
         final int oldEnd = unboundedOldEnd > mText.length() ? mText.length() : unboundedOldEnd;
         // new end should always match text
         if (start != 0 && unboundedNewEnd != (start + text.length())) {
-            throw new IllegalArgumentException("newEnd does not match text");
+            throw new IllegalArgumentException("newEnd does not match text: " +
+                unboundedNewEnd + " vs " + (start + text.length()));
         }
         final int newEnd = start + text.length();
 
         /* Text changes affect the selection as well, and we may not receive another selection
            update as a result of selection notification masking on the Gecko side; therefore,
            in order to prevent previous stale selection notifications from occurring, we need
            to increment the seqno here as well */
         ++mGeckoUpdateSeqno;
@@ -1082,17 +1088,18 @@ final class GeckoEditable
     }
 
     @Override
     public Editable replace(int st, int en,
             CharSequence source, int start, int end) {
 
         CharSequence text = source;
         if (start < 0 || start > end || end > text.length()) {
-            throw new IllegalArgumentException("invalid replace offsets");
+            throw new IllegalArgumentException("invalid replace offsets: " +
+                start + " to " + end + ", length: " + text.length());
         }
         if (start != 0 || end != text.length()) {
             text = text.subSequence(start, end);
         }
         if (mFilters != null) {
             // Filter text before sending the request to Gecko
             for (int i = 0; i < mFilters.length; ++i) {
                 final CharSequence cs = mFilters[i].filter(