code: public PersistException toPersistException(Throwable e) {
          PersistException pe = transformIntoPersistException(e);
          if (pe != null) {
              return pe;
          }
  
          Throwable cause = e.getCause();
          if (cause != null) {
              pe = transformIntoPersistException(cause);
              if (pe != null) {
                  return pe;
              }
          } else {
              cause = e;
          }
  
          return new PersistException(cause);
      }
docs: Transforms the given throwable into an appropriate persist exception. If
  it already is a persist exception, it is simply casted.
  
  @param e required exception to transform
  @return PersistException, never null