Skip to content

Commit

Permalink
fix: 좋아요를 눌렀는지 확인하는 통신에 대한 서킷브레이커의 예외 처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Oct 24, 2024
1 parent 6a1174e commit 7d397e4
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.wl2c.elswhereproductservice.global.error.exception.UnexpectedException;
import feign.FeignException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.circuitbreaker.CircuitBreaker;
import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory;
Expand All @@ -26,9 +27,11 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeoutException;

@Service
@RequiredArgsConstructor
@Slf4j
public class CachedLikeServiceImpl implements LikeService {

private final CircuitBreakerFactory circuitBreakerFactory;
Expand Down Expand Up @@ -78,10 +81,18 @@ public boolean isLiked(Long productId, Long userId) {
throwable -> {
if (throwable instanceof FeignException feignException) {
if (feignException.status() == 404) {
log.error("productId: {}, userId: {} 해당 상품에 대한 좋아요를 누른 기록을 찾을 수 없습니다: {}", productId, userId, throwable.getMessage());
return Boolean.FALSE;
}
}
throw new UnexpectedException(throwable);

if (throwable instanceof TimeoutException) {
log.error("productId: {}, userId: {} 요청 시간이 초과되었습니다: {}", productId, userId, throwable.getMessage());
return Boolean.FALSE;
}

log.error("productId: {}, userId: {} 예기치 않은 오류가 발생했습니다: {}", productId, userId, throwable.getMessage());
return Boolean.FALSE;
}
);

Expand Down

0 comments on commit 7d397e4

Please sign in to comment.