Better error message when crashing because of an invalid Remove operation

Summary:
Error messages like P131885276 don't help debugging, even when all mount instructions are logged to logcat. This log would help identify the incorrect mount instruction.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21735940

fbshipit-source-id: 16ff315c11ccafdd75d0ad9c7c60b7be2cd73202
This commit is contained in:
Joshua Gross
2020-05-26 23:29:06 -07:00
committed by Facebook GitHub Bot
parent 6a78b32878
commit 1a77943e8b
@@ -242,6 +242,17 @@ public class MountingManager {
throw new IllegalStateException("Unable to find view for tag " + parentTag);
}
if (parentView.getChildCount() <= index) {
throw new IllegalStateException(
"Cannot remove child at index "
+ index
+ " from parent ViewGroup ["
+ parentView.getId()
+ "], only "
+ parentView.getChildCount()
+ " children in parent");
}
getViewGroupManager(viewState).removeViewAt(parentView, index);
}