diff --git a/slack-api-client/src/main/java/com/slack/api/methods/MethodsCompletionException.java b/slack-api-client/src/main/java/com/slack/api/methods/MethodsCompletionException.java index 2749d48a8..e0f7d65d0 100644 --- a/slack-api-client/src/main/java/com/slack/api/methods/MethodsCompletionException.java +++ b/slack-api-client/src/main/java/com/slack/api/methods/MethodsCompletionException.java @@ -1,27 +1,13 @@ package com.slack.api.methods; -import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.extern.slf4j.Slf4j; - -import java.io.IOException; /** * Wrapped exception holding the cause exception occurred in AsyncMethodsClient */ -@Data -@Slf4j -@EqualsAndHashCode(callSuper = false) +@EqualsAndHashCode(callSuper = true) public class MethodsCompletionException extends RuntimeException { - - private final IOException ioException; - private final SlackApiException slackApiException; - private final Exception otherException; - - public MethodsCompletionException(IOException ioException, SlackApiException slackApiException, Exception otherException) { - this.ioException = ioException; - this.slackApiException = slackApiException; - this.otherException = otherException; + public MethodsCompletionException(Exception cause) { + super(cause); } - } diff --git a/slack-api-client/src/main/java/com/slack/api/methods/impl/AsyncRateLimitExecutor.java b/slack-api-client/src/main/java/com/slack/api/methods/impl/AsyncRateLimitExecutor.java index 98ccd8917..063997359 100644 --- a/slack-api-client/src/main/java/com/slack/api/methods/impl/AsyncRateLimitExecutor.java +++ b/slack-api-client/src/main/java/com/slack/api/methods/impl/AsyncRateLimitExecutor.java @@ -130,7 +130,7 @@ private T runWithoutQueue( return handleIOException(teamId, methodName, e); } catch (SlackApiException e) { logSlackApiException(teamId, methodName, e); - throw new MethodsCompletionException(null, e, null); + throw new MethodsCompletionException(e); } } @@ -171,7 +171,7 @@ private T enqueueThenRun( if (e.getResponse().code() == 429) { return enqueueThenRun(messageId, teamId, methodName, params, methodsSupplier); } - throw new MethodsCompletionException(null, e, null); + throw new MethodsCompletionException(e); } catch (InterruptedException e) { log.error("Got an InterruptedException (error: {})", e.getMessage(), e); throw new RuntimeException(e); @@ -180,12 +180,12 @@ private T enqueueThenRun( private static T handleRuntimeException(String teamId, String methodName, RuntimeException e) { log.error("Got an exception while calling {} API (team: {}, error: {})", methodName, teamId, e.getMessage(), e); - throw new MethodsCompletionException(null, null, e); + throw new MethodsCompletionException(e); } private static T handleIOException(String teamId, String methodName, IOException e) { log.error("Failed to connect to {} API (team: {}, error: {})", methodName, teamId, e.getMessage(), e); - throw new MethodsCompletionException(e, null, null); + throw new MethodsCompletionException(e); } private static void logSlackApiException(String teamId, String methodName, SlackApiException e) { diff --git a/slack-api-client/src/test/java/test_locally/api/methods/EqualityTest.java b/slack-api-client/src/test/java/test_locally/api/methods/EqualityTest.java index 89e134ba0..34a2d11a6 100644 --- a/slack-api-client/src/test/java/test_locally/api/methods/EqualityTest.java +++ b/slack-api-client/src/test/java/test_locally/api/methods/EqualityTest.java @@ -23,7 +23,6 @@ public void test() { .message("") .build(); - assertEquals(new MethodsCompletionException(null, null, null), new MethodsCompletionException(null, null, null)); - assertEquals(new SlackApiException(response, ""), new SlackApiException(response, "")); + assertEquals(new MethodsCompletionException(new SlackApiException(response, "")), new MethodsCompletionException(new SlackApiException(response, ""))); } } diff --git a/slack-api-client/src/test/java/test_locally/api/methods/ExceptionsTest.java b/slack-api-client/src/test/java/test_locally/api/methods/ExceptionsTest.java index 91e7aa4a1..26746a0ff 100644 --- a/slack-api-client/src/test/java/test_locally/api/methods/ExceptionsTest.java +++ b/slack-api-client/src/test/java/test_locally/api/methods/ExceptionsTest.java @@ -3,13 +3,17 @@ import com.slack.api.methods.MethodsCompletionException; import org.junit.Test; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; public class ExceptionsTest { @Test public void createMethodsCompletionException() { - MethodsCompletionException exception = new MethodsCompletionException(null, null, null); + MethodsCompletionException exception = new MethodsCompletionException(new IOException("IO error")); assertNotNull(exception); + assertEquals("IO error", exception.getMessage()); } }