Skip to content

Commit

Permalink
Merge branch 'RohanTalip-tidy' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanholtz committed Aug 4, 2020
2 parents 527db21 + ddb76c5 commit aef4ab6
Show file tree
Hide file tree
Showing 19 changed files with 887 additions and 562 deletions.
27 changes: 15 additions & 12 deletions src/main/java/com/sendgrid/APICallback.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package com.sendgrid;

/**
* An interface describing a callback mechanism for the
* asynchronous, rate limit aware API connection.
* An interface describing a callback mechanism for the asynchronous, rate limit aware API
* connection.
*/
public interface APICallback {
/**
* Callback method in case of an error.
* @param ex the error that was thrown.
*/
void error(Exception ex);

/**
* Callback method in case of a valid response.
* @param response the valid response.
*/
void response(Response response);
/**
* Callback method in case of an error.
*
* @param ex the error that was thrown.
*/
void error(Exception ex);

/**
* Callback method in case of a valid response.
*
* @param response the valid response.
*/
void response(Response response);
}
58 changes: 31 additions & 27 deletions src/main/java/com/sendgrid/RateLimitException.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
package com.sendgrid;

/**
* An exception thrown when the maximum number of retries
* have occurred, and the API calls are still rate limited.
* An exception thrown when the maximum number of retries have occurred, and the API calls are still
* rate limited.
*/
public class RateLimitException extends Exception {
private final Request request;
private final int retryCount;

/**
* Construct a new exception.
* @param request the originating request object.
* @param retryCount the number of times a retry was attempted.
*/
public RateLimitException(Request request, int retryCount) {
this.request = request;
this.retryCount = retryCount;
}
private final Request request;
private final int retryCount;

/**
* Get the originating request object.
* @return the request object.
*/
public Request getRequest() {
return this.request;
}
/**
* Construct a new exception.
*
* @param request the originating request object.
* @param retryCount the number of times a retry was attempted.
*/
public RateLimitException(Request request, int retryCount) {
this.request = request;
this.retryCount = retryCount;
}

/**
* Get the number of times the action was attemted.
* @return the retry count.
*/
public int getRetryCount() {
return this.retryCount;
}
/**
* Get the originating request object.
*
* @return the request object.
*/
public Request getRequest() {
return this.request;
}

/**
* Get the number of times the action was attemted.
*
* @return the retry count.
*/
public int getRetryCount() {
return this.retryCount;
}
}
Loading

0 comments on commit aef4ab6

Please sign in to comment.