code: public static ApplicationException wrapException(ApplicationException error, Throwable cause) {
  
  		if (cause instanceof ApplicationException)
  			return (ApplicationException) cause;
  
  		error.withCause(cause);
  		return error;
  	}
docs: Wraps another exception into specified application exception object.
  
  If original exception is of ApplicationException type it is returned without
  changes. Otherwise the original error is set as a cause to specified
  ApplicationException object.
  
  @param error an ApplicationException object to wrap the cause
  @param cause an original error object
  @return an original or newly created ApplicationException