Skip to content

Commit

Permalink
Fix exception handling for parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment committed Aug 4, 2021
1 parent 196f31f commit 6d8603e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/dv8tion/jda/api/requests/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public class Response implements Closeable
private boolean attemptedParsing = false;
private Exception exception;

public Response(@Nullable final okhttp3.Response response, @Nonnull final Exception exception, @Nonnull final Set<String> cfRays)
public Response(@Nonnull final Exception exception, @Nonnull final Set<String> cfRays)
{
this(response, response != null ? response.code() : ERROR_CODE, ERROR_MESSAGE, -1, cfRays);
this(null, ERROR_CODE, ERROR_MESSAGE, -1, cfRays);
this.exception = exception;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
Expand Down Expand Up @@ -244,21 +243,21 @@ else if (handleOnRatelimit)
catch (UnknownHostException e)
{
LOG.error("DNS resolution failed: {}", e.getMessage());
apiRequest.handleResponse(new Response(lastResponse, e, rays));
apiRequest.handleResponse(new Response(e, rays));
return null;
}
catch (IOException e)
{
if (retryOnTimeout && !retried && isRetry(e))
return execute(apiRequest, true, handleOnRatelimit);
LOG.error("There was an I/O error while executing a REST request: {}", e.getMessage());
apiRequest.handleResponse(new Response(lastResponse, e, rays));
apiRequest.handleResponse(new Response(e, rays));
return null;
}
catch (Exception e)
{
LOG.error("There was an unexpected error while executing a REST request", e);
apiRequest.handleResponse(new Response(lastResponse, e, rays));
apiRequest.handleResponse(new Response(e, rays));
return null;
}
finally
Expand Down

0 comments on commit 6d8603e

Please sign in to comment.