From 8e720b044b46e470faf6eb03df28ea6a34d04884 Mon Sep 17 00:00:00 2001 From: chentianming Date: Mon, 6 Jun 2022 10:04:46 +0800 Subject: [PATCH] RetryFailedException --- .../boot/exception/RetryFailedException.java | 16 ++++++++++++++++ .../spring/boot/retry/RetryInterceptor.java | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/github/lianjiatech/retrofit/spring/boot/exception/RetryFailedException.java 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"); }