Skip to content

Commit

Permalink
Simplify ComponentUtils.handleWithHierarchy()
Browse files Browse the repository at this point in the history
Summary: Trivial simplifications found while investigating adding metadata.

Reviewed By: mihaelao

Differential Revision: D27656006

fbshipit-source-id: d34bbb93b8df61141dd47e723eb3f25de9ea090d
  • Loading branch information
Michal Karpinski authored and facebook-github-bot committed Apr 9, 2021
1 parent 21fe396 commit 0d8ee4b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,6 @@ protected boolean shouldUpdate(
protected void transferState(
StateContainer previousStateContainer, StateContainer nextStateContainer) {}

/**
* For internal use, only. In order to reraise an error event up the hierarchy use {@link
* ComponentUtils#raise(ComponentContext, Exception)} instead.
*/
protected static void dispatchErrorEvent(ComponentContext c, Exception e) {
ComponentUtils.dispatchErrorEvent(c, e);
}

/** For internal use, only. */
public static void dispatchErrorEvent(ComponentContext c, ErrorEvent e) {
ComponentUtils.dispatchErrorEvent(c, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,7 @@ static void handleWithHierarchy(
}

final LithoMetadataExceptionWrapper metadataWrapper =
(exceptionToThrow instanceof LithoMetadataExceptionWrapper)
? (LithoMetadataExceptionWrapper) exceptionToThrow
: new LithoMetadataExceptionWrapper(parent, exceptionToThrow);
wrapWithMetadata(parent, exceptionToThrow);
metadataWrapper.addComponentForLayoutStack(component);

// This means it was already handled by this handler so throw it up to the next frame until we
Expand All @@ -535,7 +533,7 @@ static void handleWithHierarchy(
((ErrorEventHandler) nextHandler).onError(metadataWrapper);
} else { // Handle again with new handler
try {
ComponentLifecycle.dispatchErrorEvent(parent, exceptionToThrow);
dispatchErrorEvent(parent, exceptionToThrow);
} catch (ReThrownException ex) { // error handler re-raised the exception
metadataWrapper.lastHandler = nextHandler;
throw metadataWrapper;
Expand Down

0 comments on commit 0d8ee4b

Please sign in to comment.