Skip to content

Rework exception handling to attach original exception. #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions src/main/java/org/gitlab4j/api/webhook/WebHookManager.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package org.gitlab4j.api.webhook;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
Expand All @@ -15,9 +14,6 @@
import org.gitlab4j.api.utils.HttpRequestUtils;
import org.gitlab4j.api.utils.JacksonJson;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;

/**
* This class provides a handler for processing GitLab WebHook callouts.
*/
Expand Down Expand Up @@ -81,7 +77,6 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
throw new GitLabApiException(message);
}

String errorMessage = null;
try {

Event event;
Expand All @@ -98,22 +93,10 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {

fireEvent(event);

} catch (JsonParseException jpe) {
errorMessage = jpe.getMessage();
LOG.warning("Error parsing JSON data, error=" + errorMessage);
} catch (JsonMappingException jme) {
errorMessage = jme.getMessage();
LOG.warning("Error mapping JSON data, error=" + errorMessage);
} catch (IOException ioe) {
errorMessage = ioe.getMessage();
LOG.warning("Error reading JSON data, error=" + errorMessage);
} catch (Exception e) {
errorMessage = e.getMessage();
LOG.warning("Unexpected error reading JSON data, error=" + errorMessage);
LOG.warning("Error parsing JSON data, exception=" + e.getClass().getSimpleName() + ", error=" + e.getMessage());
throw new GitLabApiException(e);
}

if (errorMessage != null)
throw new GitLabApiException(errorMessage);
}

/**
Expand Down