40 lines
1.5 KiB
Java
40 lines
1.5 KiB
Java
/************************************************************
|
|
*
|
|
* @packageName : io.company.localhost.common.exception
|
|
* @fileName : NotFoundHandler.java
|
|
* @author : 조인제
|
|
* @date : 24.12.06
|
|
* @description :
|
|
*
|
|
* ===========================================================
|
|
* DATE AUTHOR NOTE
|
|
* -----------------------------------------------------------
|
|
* 24.12.06 조인제 최초 생성
|
|
*
|
|
*************************************************************/
|
|
package io.company.localhost.common.exception;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
|
|
|
import io.company.localhost.common.exception.code.CommonErrorCode;
|
|
import io.company.localhost.common.exception.code.ErrorCode;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@Slf4j
|
|
@RestControllerAdvice
|
|
public class NotFoundHandler {
|
|
|
|
@ResponseStatus(HttpStatus.NOT_FOUND)
|
|
@ExceptionHandler(NoHandlerFoundException.class)
|
|
public ResponseEntity<Object> noHandlerFoundArgument(NoHandlerFoundException e) {
|
|
log.warn("NoHandlerFoundException", e);
|
|
ErrorCode errorCode = CommonErrorCode.RESOURCE_NOT_FOUND;
|
|
return ErrorResult.handleExceptionInternal(errorCode, errorCode.getMessage());
|
|
}
|
|
}
|