private void sendFinalState() { final FragmentState outcome = fragmentState.get(); if (outcome == FragmentState.FAILED) { final FragmentHandle handle = getContext().getHandle(); final UserException uex = UserException.systemError(deferredException.getAndClear()) .addIdentity(getContext().getIdentity()) .addContext( "Fragment", handle.getMajorFragmentId() + ":" + handle.getMinorFragmentId()) .build(logger); statusReporter.fail(uex); } else { statusReporter.stateChanged(outcome); } }
/** * Capture an exception and add store it. Update state to failed status (if not already there). * Does not immediately report status back to Foreman. Only the original thread can return status * to the Foreman. * * @param excep The failure that occurred. */ private void fail(final Throwable excep) { deferredException.addThrowable(excep); updateState(FragmentState.FAILED); }