Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

이미지 파일 관련 에러 추적을 위한 코드 추가 #208

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PostController {
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<Void> save(
@RequestPart(name = "request") @Valid final PostCreateRequest request,
@RequestPart(name = "contentImages") final List<MultipartFile> contentImages,
@RequestPart(name = "contentImages", required = false) final List<MultipartFile> contentImages,
@RequestPart(name = "optionImages") final List<MultipartFile> optionImages,
@Auth final Member loginMember
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.multipart.support.MissingServletRequestPartException;

@Slf4j
@RestControllerAdvice
Expand Down Expand Up @@ -76,4 +77,15 @@ public ResponseEntity<ExceptionResponse> handleMultipartException(final Multipar
.body(ExceptionResponse.from(new BadRequestException(PostExceptionType.WRONG_IMAGE)));
}

@ExceptionHandler
public ResponseEntity<ExceptionResponse> handleMissingServletRequestPartException(final MissingServletRequestPartException e) {
System.out.println("================================");
System.out.println("GlobalExceptionHandler.handleMissingServletRequestPartException");
e.printStackTrace();

log.warn("[" + e.getClass() + "] : " + e.getMessage());
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(ExceptionResponse.from(new BadRequestException(PostExceptionType.WRONG_IMAGE)));
}

}