private boolean isCauseException(Throwable ex,Class<?> clazz,int maxLevels){
  if (maxLevels > 0) {
    Throwable cause=ex.getCause();
    if (cause != null) {
      return clazz.isInstance(cause) || isCauseException(cause,clazz,maxLevels - 1);
    }
  }
  return false;
}

private boolean isCauseException ( Throwable ex , Class < ? > clazz , int maxLevels ) { if ( maxLevels > 0 ) { Throwable cause = ex . getCause ( ) ; if ( cause != null ) { return clazz . isInstance ( cause ) || isCauseException ( cause , clazz , maxLevels - 1 ) ; } } return false ; }
detect if the root cause of the exception is a specific orientdb exception this is necessary as the database may wrap this root cause in further exceptions , masking the underlying cause
