issue # GlobalExceptionHandler 파일 수정

This commit is contained in:
민건희
2025-11-04 19:57:43 +09:00
parent 32ea24ead5
commit ed9e17bb0f
2 changed files with 52 additions and 48 deletions

View File

@@ -5,11 +5,15 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.time.LocalDateTime; import com.baekyangdan.scheduler.exception.AuthException;
import com.baekyangdan.scheduler.exception.BusinessException;
import com.baekyangdan.scheduler.exception.ValidationException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class ExceptionHandler { @RestControllerAdvice
public class GlobalExceptionHandler {
// 에러 핸들러 목록 // 에러 핸들러 목록
// 1. 비즈니스 로직 관련 예외 처리 // 1. 비즈니스 로직 관련 예외 처리
// ex) 중복 데이터 // ex) 중복 데이터
@@ -32,7 +36,7 @@ public class ExceptionHandler {
// 3. 권한/인가 관련 예외 처리 // 3. 권한/인가 관련 예외 처리
// ex) 로그인이 필요한 서비스에 로그인 사람이 호출 // ex) 로그인이 필요한 서비스에 로그인 사람이 호출
@ExceptionHandler(AuthException.class) @ExceptionHandler(AuthException.class)
public ResponseEntity<Map<String, Object>> handleValidationException(ValidationException e) { public ResponseEntity<Map<String, Object>> handleAuthException(ValidationException e) {
Map<String, Object> body = new HashMap<>(); Map<String, Object> body = new HashMap<>();
body.put("message", e.getMessage()); body.put("message", e.getMessage());
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(body); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(body);

View File

@@ -11,7 +11,7 @@ public class RandomCodeGenerator {
private static final SecureRandom random = new SecureRandom(); private static final SecureRandom random = new SecureRandom();
public static String generateRandomCode(int length) { public static String generateRandomCode(int length) {
List<Character> codeCharacters = ArrayList<>(length); List<Character> codeCharacters = new ArrayList<>(length);
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
codeCharacters.add(randomChar()); codeCharacters.add(randomChar());