Commit 320e88c9 authored by Tiaan Louw's avatar Tiaan Louw Committed by Greg Messner
Browse files

Rework exception handling to attach original exception. (#125)

* Rework exception handling so that original exception is attached to GitlabApiException.
* Simplify exception handling, but keeping relevant data.
* Remove unused imports
parent 2a4affef
package org.gitlab4j.api.webhook; package org.gitlab4j.api.webhook;
import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
...@@ -15,9 +14,6 @@ import org.gitlab4j.api.HookManager; ...@@ -15,9 +14,6 @@ import org.gitlab4j.api.HookManager;
import org.gitlab4j.api.utils.HttpRequestUtils; import org.gitlab4j.api.utils.HttpRequestUtils;
import org.gitlab4j.api.utils.JacksonJson; 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. * This class provides a handler for processing GitLab WebHook callouts.
*/ */
...@@ -81,7 +77,6 @@ public class WebHookManager extends HookManager { ...@@ -81,7 +77,6 @@ public class WebHookManager extends HookManager {
throw new GitLabApiException(message); throw new GitLabApiException(message);
} }
String errorMessage = null;
try { try {
Event event; Event event;
...@@ -98,22 +93,10 @@ public class WebHookManager extends HookManager { ...@@ -98,22 +93,10 @@ public class WebHookManager extends HookManager {
fireEvent(event); 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) { } catch (Exception e) {
errorMessage = e.getMessage(); LOG.warning("Error parsing JSON data, exception=" + e.getClass().getSimpleName() + ", error=" + e.getMessage());
LOG.warning("Unexpected error reading JSON data, error=" + errorMessage); throw new GitLabApiException(e);
} }
if (errorMessage != null)
throw new GitLabApiException(errorMessage);
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment