Skip to content

Exceptions should never be propagated as a generic Java Error #275

Closed

Description

@mjpitz

This tends to cause processes to crash as no-one catches this type of error. From what I can tell, it looks like we are re-boxing the GitlabAPIexception with a java.lang.Error.

java.lang.Error: org.gitlab.api.GitlabAPIException: {"message":"403 Forbidden"}
	at org.gitlab.api.http.GitlabHTTPRequestor$1.fetch(GitlabHTTPRequestor.java:263)
	at org.gitlab.api.http.GitlabHTTPRequestor$1.hasNext(GitlabHTTPRequestor.java:217)
	at org.gitlab.api.http.GitlabHTTPRequestor.getAll(GitlabHTTPRequestor.java:185)
	at org.gitlab.api.GitlabAPI.getRepositoryTree(GitlabAPI.java:1563)

Activity

  1. mjpitz commented on Dec 18, 2017

    @mjpitz
    ContributorAuthor

    Looking at the code really quick, I see this double try catch causing the issue:

                    try {
                        HttpURLConnection connection = setupConnection(url);
                        try {
                            next = parse(connection, type, null);
                            assert next != null;
                            findNextUrl();
                        } catch (IOException e) {
                            handleAPIError(e, connection);
                        }
                    } catch (IOException e) {
                        throw new Error(e);
                    }
    
  2. timols commented on Dec 22, 2017

    @timols
    Owner

    @jpitz you make a very good point. Would you be ok to submit a PR for this change?

  3. mjpitz commented on Dec 22, 2017

    @mjpitz
    ContributorAuthor
  4. mjpitz commented on Jan 5, 2018

    @mjpitz
    ContributorAuthor

    @timols : feel free to assign to me if possible. I should have something up today.

  5. mjpitz commented on Jan 5, 2018

    @mjpitz
    ContributorAuthor

    Pull request here: #281

  6. added a commit that references this issue on Jan 5, 2018
  7. jaredhodge commented on Oct 4, 2018

    @jaredhodge

    @timols ; how about spinning a new version of the library and propagating it out maven central so people can take advantage of this fix?

  8. jaredhodge commented on Oct 16, 2018

    @jaredhodge

    I see 4.1.0 out there now. Thanks @timols!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions