Skip to content

Commit

Permalink
Add support to FabricUIManger to handle Throwable
Browse files Browse the repository at this point in the history
Reviewed By: achen1

Differential Revision: D7168684

fbshipit-source-id: c655730b5bf5e181974096c2b940f6457be8a40d
  • Loading branch information
mdvacca authored and facebook-github-bot committed Mar 6, 2018
1 parent 6eef7de commit d2f0574
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public ReactShadowNode createNode(int reactTag,
mUIViewOperationQueue
.enqueueCreateView(rootNode.getThemedContext(), reactTag, viewName, styles);
return node;
} catch (Exception e) {
handleException(rootTag, e);
} catch (Throwable t) {
handleException(getRootNode(rootTag), t);
return null;
}
}
Expand Down Expand Up @@ -103,8 +103,8 @@ public ReactShadowNode cloneNode(ReactShadowNode node) {
ReactShadowNode clone = node.mutableCopy();
assertReactShadowNodeCopy(node, clone);
return clone;
} catch (Exception e) {
handleException(node.getThemedContext(), e);
} catch (Throwable t) {
handleException(node, t);
return null;
}
}
Expand All @@ -120,8 +120,8 @@ public ReactShadowNode cloneNodeWithNewChildren(ReactShadowNode node) {
ReactShadowNode clone = node.mutableCopyWithNewChildren();
assertReactShadowNodeCopy(node, clone);
return clone;
} catch (Exception e) {
handleException(node.getThemedContext(), e);
} catch (Throwable t) {
handleException(node, t);
return null;
}
}
Expand All @@ -140,8 +140,8 @@ public ReactShadowNode cloneNodeWithNewProps(
updateProps(clone, newProps);
assertReactShadowNodeCopy(node, clone);
return clone;
} catch (Exception e) {
handleException(node.getThemedContext(), e);
} catch (Throwable t) {
handleException(node, t);
return null;
}
}
Expand All @@ -161,9 +161,8 @@ public ReactShadowNode cloneNodeWithNewChildrenAndProps(
updateProps(clone, newProps);
assertReactShadowNodeCopy(node, clone);
return clone;
} catch (Exception e) {
handleException(node.getThemedContext(), e);
getRootNode(1).getThemedContext().handleException(e);
} catch (Throwable t) {
handleException(node, t);
return null;
}
}
Expand Down Expand Up @@ -191,8 +190,8 @@ public void appendChild(ReactShadowNode parent, ReactShadowNode child) {
viewsToAdd,
null
);
} catch (Exception e) {
handleException(parent.getThemedContext(), e);
} catch (Throwable t) {
handleException(parent, t);
}
}

Expand Down Expand Up @@ -227,7 +226,7 @@ public void completeRoot(int rootTag, List<ReactShadowNode> childList) {
mUIViewOperationQueue
.dispatchViewUpdates(1, System.currentTimeMillis(), System.currentTimeMillis());
} catch (Exception e) {
handleException(rootTag, e);
handleException(getRootNode(rootTag), e);
}
}

Expand Down Expand Up @@ -332,16 +331,16 @@ public void updateRootView(
}
}

private void handleException(ThemedReactContext context, Exception e) {
private void handleException(ReactShadowNode node, Throwable t) {
try {
context.handleException(e);
ThemedReactContext context = node.getThemedContext();
// TODO move exception management to JNI side, and refactor to avoid wrapping Throwable into
// a RuntimeException
context.handleException(new RuntimeException(t));
} catch (Exception ex) {
Log.e(TAG, "Exception while executing a Fabric method", e);
throw new RuntimeException(ex.getMessage(), e);
Log.e(TAG, "Exception while executing a Fabric method", t);
throw new RuntimeException(ex.getMessage(), t);
}
}

private void handleException(int rootTag, Exception e) {
handleException(getRootNode(rootTag).getThemedContext(), e);
}
}

0 comments on commit d2f0574

Please sign in to comment.