code: public static QueryException fromThrowable(Throwable cause) {
      return (cause instanceof QueryException)
                     ? (QueryException) cause
                     : new QueryException(cause);
    }
docs: Converts a Throwable to a QueryException. If the Throwable is a QueryException, it will be
  passed through unmodified; otherwise, it will be wrapped in a new QueryException.
  
  @param cause the Throwable to convert
  
  @return a QueryException