From 7bf61964084648bbde603c95f7c4734d30387a10 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 4 Aug 2020 14:13:16 -0700 Subject: [PATCH] Collect more diagnostics when `addViewAt` crashes Summary: Making error more explicit to assist in debugging. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D22929047 fbshipit-source-id: 4f26668a96868e7c5865a587142c3bcd10a26c90 --- .../react/fabric/mounting/MountingManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 3c33450fc14..cd9fdea1c09 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -156,7 +156,19 @@ public class MountingManager { logViewHierarchy(parentView); } - getViewGroupManager(parentViewState).addView(parentView, view, index); + try { + getViewGroupManager(parentViewState).addView(parentView, view, index); + } catch (IllegalStateException e) { + // Wrap error with more context for debugging + throw new IllegalStateException( + "addViewAt: failed to insert view [" + + tag + + "] into parent [" + + parentTag + + "] at index " + + index, + e); + } // Display children after inserting if (SHOW_CHANGED_VIEW_HIERARCHIES) {