Skip to content

Commit

Permalink
refactor: (#189) undefined 된 이미지 파일에 대한 디버깅을 위해 MultipartException의 E…
Browse files Browse the repository at this point in the history
…xceptionHandler 추가 (#191)
  • Loading branch information
tjdtls690 committed Sep 12, 2023
1 parent 95b492e commit e3a42ac
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.votogether.exception;

import com.votogether.domain.post.exception.PostExceptionType;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.MultipartException;

@Slf4j
@RestControllerAdvice
Expand Down Expand Up @@ -64,4 +65,15 @@ public ResponseEntity<ExceptionResponse> handleNotFoundException(final NotFoundE
.body(ExceptionResponse.from(e));
}

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

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

}

0 comments on commit e3a42ac

Please sign in to comment.