java-gitlab-api icon indicating copy to clipboard operation
java-gitlab-api copied to clipboard

getGroups() throws java.lang.Error for token with insufficient scope

Open john-french opened this issue 8 years ago • 0 comments

(Applies to v1.2.8 and current GitLab.com, 10.2.2).

Calling GitlabAPI.getGroups() when the instance of GitlabAPI was created with a token with insufficient scope (e.g. read_user) throws a java.lang.Error. Calling code needs to catch Throwable to ensure it catches the methods declared IOException and this potential error.

This scenario should throw a subclass of Exception (e.g. IOException or GitlabAPIException) rather than Error.

Error is thrown here https://github.com/timols/java-gitlab-api/blob/20d3c7dbac3a23909c2c3d84ee26bb45953b5e3b/src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java#L263

john-french avatar Dec 07 '17 17:12 john-french