Use Durations everywhere, drop unused constructors, and add tests.

This commit is contained in:
Jon Chambers
2021-03-05 12:06:26 -05:00
committed by Jon Chambers
parent 1faedd3870
commit af2a8548c3
8 changed files with 56 additions and 32 deletions

View File

@@ -10,19 +10,14 @@ public class RateLimitExceededException extends Exception {
private final Duration retryDuration;
public RateLimitExceededException() {
public RateLimitExceededException(final Duration retryDuration) {
super();
retryDuration = Duration.ZERO;
this.retryDuration = retryDuration;
}
public RateLimitExceededException(String message) {
public RateLimitExceededException(final String message, final Duration retryDuration) {
super(message);
retryDuration = Duration.ZERO;
}
public RateLimitExceededException(String message, long retryAfterMillis) {
super(message);
retryDuration = Duration.ofMillis(retryAfterMillis);
this.retryDuration = retryDuration;
}
public Duration getRetryDuration() { return retryDuration; }

View File

@@ -10,14 +10,8 @@ import java.time.Duration;
public class RetryLaterException extends Exception {
private final Duration backoffDuration;
public RetryLaterException() {
backoffDuration = Duration.ZERO;
}
public RetryLaterException(int retryLaterMillis) {
backoffDuration = Duration.ofMillis(retryLaterMillis);
}
public RetryLaterException(RateLimitExceededException e) {
super(e);
this.backoffDuration = e.getRetryDuration();
}