code: public static void logAndThrowException(Exception ex, AbstractInvokable parent) throws Exception {
  		String taskName;
  		if (ex instanceof ExceptionInChainedStubException) {
  			do {
  				ExceptionInChainedStubException cex = (ExceptionInChainedStubException) ex;
  				taskName = cex.getTaskName();
  				ex = cex.getWrappedException();
  			} while (ex instanceof ExceptionInChainedStubException);
  		} else {
  			taskName = parent.getEnvironment().getTaskName();
  		}
  
  		if (LOG.isErrorEnabled()) {
  			LOG.error(constructLogString("Error in task code", taskName, parent), ex);
  		}
  
  		throw ex;
  	}
docs: Prints an error message and throws the given exception. If the exception is of the type
  {@link ExceptionInChainedStubException} then the chain of contained exceptions is followed
  until an exception of a different type is found.
  
  @param ex The exception to be thrown.
  @param parent The parent task, whose information is included in the log message.
  @throws Exception Always thrown.