jfrog / artifactory-client-java

Artifactory REST Client Java API bindings
Apache License 2.0
319 stars 153 forks source link

IOExceptions are thrown as InvocationTargetException #224

Open cyrilc-pro opened 6 years ago

cyrilc-pro commented 6 years ago

Due to the Groovy/Java mix, when the Groovy implementation of a method throws an IOException, the exception is actually wrapped in an InvocationTargetException.

Example:

    LocalRepository localRepository =
        RepositoryBuildersImpl.create().localRepositoryBuilder()
            .key(REPOSITORY)
            .repoLayoutRef(new GenericRepositorySettingsImpl().getRepoLayout()).build();
    client.repositories().create(-1, localRepository);

The last line can throw IOException, but it is not declared in the interface method org.jfrog.artifactory.client.Repositories.create(int,Repository).

If the caller wishes to catch the exception, he needs to catch InvocationTargetException instead of IOException.

The fix simply consists of adding IOException to all interface methods whose implementation is actually a REST call.

cyrilc-pro commented 6 years ago

Similar to #216