Skip to content

Commit 2a4affe

Browse files
committed
Simplified exception handling and logging of same.
1 parent 988f71c commit 2a4affe

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/main/java/org/gitlab4j/api/systemhooks/SystemHookManager.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
package org.gitlab4j.api.systemhooks;
33

4-
import java.io.IOException;
54
import java.io.InputStreamReader;
65
import java.util.List;
76
import java.util.concurrent.CopyOnWriteArrayList;
@@ -15,9 +14,6 @@
1514
import org.gitlab4j.api.utils.HttpRequestUtils;
1615
import org.gitlab4j.api.utils.JacksonJson;
1716

18-
import com.fasterxml.jackson.core.JsonParseException;
19-
import com.fasterxml.jackson.databind.JsonMappingException;
20-
2117
/**
2218
* This class provides a handler for processing GitLab System Hook callouts.
2319
*/
@@ -71,7 +67,6 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
7167
throw new GitLabApiException(message);
7268
}
7369

74-
String errorMessage = null;
7570
try {
7671

7772
SystemHookEvent event;
@@ -88,22 +83,11 @@ public void handleEvent(HttpServletRequest request) throws GitLabApiException {
8883

8984
fireEvent(event);
9085

91-
} catch (JsonParseException jpe) {
92-
errorMessage = jpe.getMessage();
93-
LOG.warning("Error parsing JSON data, error=" + errorMessage);
94-
} catch (JsonMappingException jme) {
95-
errorMessage = jme.getMessage();
96-
LOG.warning("Error mapping JSON data, error=" + errorMessage);
97-
} catch (IOException ioe) {
98-
errorMessage = ioe.getMessage();
99-
LOG.warning("Error reading JSON data, error=" + errorMessage);
10086
} catch (Exception e) {
101-
errorMessage = e.getMessage();
102-
LOG.warning("Unexpected error reading JSON data, error=" + errorMessage);
87+
LOG.warning("Error processing JSON data, exception=" +
88+
e.getClass().getSimpleName() + ", error=" + e.getMessage());
89+
throw new GitLabApiException(e);
10390
}
104-
105-
if (errorMessage != null)
106-
throw new GitLabApiException(errorMessage);
10791
}
10892

10993
/**

0 commit comments

Comments
 (0)