Skip to content

Commit

Permalink
fix: updated return to throw
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Oct 12, 2024
1 parent 6ccbfd3 commit cb40557
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.smeem.http.aspect;

import com.smeem.common.exception.ExceptionCode;
import com.smeem.http.controller.dto.ExceptionResponse;
import com.smeem.common.exception.SmeemException;
import lombok.val;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
Expand All @@ -33,7 +32,7 @@ public Object duplicateRequestCheck(ProceedingJoinPoint joinPoint) throws Throwa
val requestId = joinPoint.getSignature().toLongString();
if (requestSet.contains(requestId)) {
// 중복 요청인 경우
return handleDuplicateRequest();
throw new SmeemException(ExceptionCode.TOO_MANY_REQUESTS);
}
requestSet.add(requestId);

Expand All @@ -43,10 +42,4 @@ public Object duplicateRequestCheck(ProceedingJoinPoint joinPoint) throws Throwa
requestSet.remove(requestId);
}
}

private ResponseEntity<ExceptionResponse> handleDuplicateRequest() {
return ResponseEntity
.status(ExceptionCode.TOO_MANY_REQUESTS.getStatusCode())
.body(ExceptionResponse.of(ExceptionCode.TOO_MANY_REQUESTS.getMessage() + ": 중복된 요청"));
}
}

0 comments on commit cb40557

Please sign in to comment.