에러 메세지

yesrin·2023년 7월 12일

Spring

목록 보기
9/18

에러메세지 관리. 살펴보기.

전체코드

 @ExceptionHandler({IllegalArgumentException.class})
    public ResponseEntity<RestApiException> illegalArgumentExceptionHandler(IllegalArgumentException ex) {
        RestApiException restApiException = new RestApiException(ex.getMessage(), HttpStatus.BAD_REQUEST.value());
        return new ResponseEntity<>(
                // HTTP body
                restApiException,
                // HTTP status code  
                HttpStatus.BAD_REQUEST
        );
    }

response에 반환 코드

RestApiException restApiException = new RestApiException(ex.getMessage(), HttpStatus.BAD_REQUEST.value());

Status 반환 코드

return new ResponseEntity<>(
                // HTTP body
                restApiException,
                // HTTP status code
                HttpStatus.BAD_REQUEST
        );


웹페이지에서는 f12 개발자 도구 네트워크에 400에로 표시됨.

profile
안녕하세요! 틀린 정보는 댓글 달아 주세요.

0개의 댓글