artifactory-client-java icon indicating copy to clipboard operation
artifactory-client-java copied to clipboard

IOExceptions are thrown as InvocationTargetException

Open cyrilc-pro opened this issue 6 years ago • 1 comments

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 avatar Oct 15 '18 14:10 cyrilc-pro

Similar to #216

cyrilc-pro avatar Oct 15 '18 15:10 cyrilc-pro