31 lines
1.3 KiB
Java
31 lines
1.3 KiB
Java
package com.goldenchart.controller;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
|
import org.springframework.web.multipart.MultipartException;
|
|
|
|
import java.util.Map;
|
|
|
|
@RestControllerAdvice
|
|
@Slf4j
|
|
public class VerificationUploadExceptionHandler {
|
|
|
|
@ExceptionHandler(MaxUploadSizeExceededException.class)
|
|
public ResponseEntity<Map<String, String>> handleMaxUpload(MaxUploadSizeExceededException e) {
|
|
log.warn("[VerificationUpload] size exceeded: {}", e.getMessage());
|
|
return ResponseEntity.status(HttpStatus.PAYLOAD_TOO_LARGE)
|
|
.body(Map.of("message", "업로드 용량이 제한(30MB)을 초과했습니다."));
|
|
}
|
|
|
|
@ExceptionHandler(MultipartException.class)
|
|
public ResponseEntity<Map<String, String>> handleMultipart(MultipartException e) {
|
|
log.warn("[VerificationUpload] multipart error: {}", e.getMessage());
|
|
return ResponseEntity.badRequest()
|
|
.body(Map.of("message", "이미지 파일 형식을 확인할 수 없습니다."));
|
|
}
|
|
}
|