protected void executeWithErrorPropagation(ActivityExecution execution, Callable<Void> toExecute) throws Exception {
    String activityInstanceId = execution.getActivityInstanceId();
    try {
      toExecute.call();
    } catch (Exception ex) {
      if (activityInstanceId.equals(execution.getActivityInstanceId())) {

        try {
          propagateException(execution, ex);
        }
        catch (ErrorPropagationException e) {
          LOG.errorPropagationException(activityInstanceId, e.getCause());
          // re-throw the original exception so that it is logged
          // and set as cause of the failure
          throw ex;
        }

      }
      else {
        throw ex;
      }
    }
  }
protected void executeWithErrorPropagation ( ActivityExecution execution , Callable < Void > toExecute ) throws Exception { String activityInstanceId = execution . getActivityInstanceId ( ) ; try { toExecute . call ( ) ; } catch ( Exception ex ) { if ( activityInstanceId . equals ( execution . getActivityInstanceId ( ) ) ) { try { propagateException ( execution , ex ) ; } catch ( ErrorPropagationException e ) { LOG . errorPropagationException ( activityInstanceId , e . getCause ( ) ) ; throw ex ; } } else { throw ex ; } } }
Takes an {@link ActivityExecution} and an {@link Callable} and wraps
the call to the Callable with the proper error propagation. This method
also makes sure that exceptions not caught by following activities in the
process will be thrown and not propagated.

@param execution
@param toExecute
@throws Exception