code: public static WatchingException createWatchingException(InvocationTargetException exception, File file) {
          Throwable cause = exception.getTargetException();
          if (WatchingException.class.getName().equals(exception.getTargetException().getClass().getName())) {
              try {
                  Method line = cause.getClass().getMethod("getLine");
                  Method character = cause.getClass().getMethod("getCharacter");
                  Method source = cause.getClass().getMethod("getFile");
                  Method title = cause.getClass().getMethod("getTitle");
  
                  return new WatchingException(
                          (String) title.invoke(cause),
                          cause.getMessage(),
                          (File) source.invoke(cause),
                          (Integer) line.invoke(cause),
                          (Integer) character.invoke(cause),
                          cause.getCause());
              } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
                  throw new IllegalArgumentException("Cannot create the watching exception from " + cause);
              }
          } else {
              return new WatchingException(cause.getMessage(), file, cause);
          }
      }
docs: Even {@link org.wisdom.maven.WatchingException} cannot be used directly, so we need to use reflection to
  recreate the exception with the same content.
  <p>
  This method checks if the cause of the {@link java.lang.reflect
  .InvocationTargetException} is a {@link org.wisdom.maven.WatchingException},
  in this case if create an exception with the same content. Otherwise it creates a new {@link org.wisdom.maven
  .WatchingException} from the given exception's cause.
  
  @param exception the invocation target exception caught by the delegate
  @param file      the file having thrown the exception (the processed file).
  @return a Watching Exception containing the content from the given exception if possible or a new exception
  from the {@literal exception}'s cause.