diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/exception/RetryFailedException.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/exception/RetryFailedException.java new file mode 100644 index 0000000..c6a7b49 --- /dev/null +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/exception/RetryFailedException.java @@ -0,0 +1,16 @@ +package com.github.lianjiatech.retrofit.spring.boot.exception; + +/** + * @author 陈添明 + * @since 2022/6/6 9:59 上午 + */ +public class RetryFailedException extends RuntimeException { + + public RetryFailedException(String message) { + super(message); + } + + public RetryFailedException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/RetryInterceptor.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/RetryInterceptor.java index 2cec77a..156ecf3 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/RetryInterceptor.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/RetryInterceptor.java @@ -7,6 +7,7 @@ import java.util.Objects; import java.util.stream.Collectors; +import com.github.lianjiatech.retrofit.spring.boot.exception.RetryFailedException; import com.github.lianjiatech.retrofit.spring.boot.util.AnnotationExtendUtils; import lombok.extern.slf4j.Slf4j; @@ -80,7 +81,7 @@ protected Response retryIntercept(int maxRetries, int intervalMs, RetryRule[] re } else { if (!retryStrategy.shouldRetry()) { // 最后一次还没成功,抛出异常 - throw new RuntimeException("Retry Failed: Total " + maxRetries + throw new RetryFailedException("Retry Failed: Total " + maxRetries + " attempts made at interval " + intervalMs + "ms"); }