반응형
💋 오늘 공부한 내용
- 백엔드 RestDocs + Swagger 적용을 해보고 있다.
- 애플리케이션에서 사용하는 Request DTO에 Validation을 위한 어노테이션을 모두 추가했다.
- 이때 좀 놀라운게 Boolean 타입의 경우에는 wrapper class인지 아닌지를 특히나 주의해서 사용해야 한다는 것을 지난번에 크루들에게 들었는데, 오늘 또 한번 당했다.
- 롬복으로 @Getter를 사용했을 때, isUsed라는 필드에 대해서 Boolean은 getIsUsed로 getter가 만들어지고, boolean은 isUsed로 만들어진다는 것을 알게 되었음.
- 자세한 내용은 레오가 포스팅했었으니 참고!
- 오늘은 꼭 인수테스트, 통합테스트를 위한 테스트 템플릿을 만들고 말겠어!
- 전역 예외 처리를 했다.
- public class GlobalExceptionHandler extends ResponseEntityExceptionHandler처럼 ExceptionHandler에 ResponseEntityExceptionHandler를 상속받으면, 아래와 같은 모든 메서드를 사용할 수 있다는 것을 제나한테 배웠다.
@ExceptionHandler({
HttpRequestMethodNotSupportedException.class,
HttpMediaTypeNotSupportedException.class,
HttpMediaTypeNotAcceptableException.class,
MissingPathVariableException.class,
MissingServletRequestParameterException.class,
MissingServletRequestPartException.class,
ServletRequestBindingException.class,
MethodArgumentNotValidException.class,
NoHandlerFoundException.class,
AsyncRequestTimeoutException.class,
ErrorResponseException.class,
ConversionNotSupportedException.class,
TypeMismatchException.class,
HttpMessageNotReadableException.class,
HttpMessageNotWritableException.class,
BindException.class
})
@Nullable
public final ResponseEntity<Object> handleException(Exception ex, WebRequest request) throws Exception {
if (ex instanceof HttpRequestMethodNotSupportedException subEx) {
return handleHttpRequestMethodNotSupported(subEx, subEx.getHeaders(), subEx.getStatusCode(), request);
}
else if (ex instanceof HttpMediaTypeNotSupportedException subEx) {
return handleHttpMediaTypeNotSupported(subEx, subEx.getHeaders(), subEx.getStatusCode(), request);
}
// ...
}
}
💋 감정 회고
💋 오늘 공부한 글
https://jwkim96.tistory.com/274
https://techblog.woowahan.com/2597/
반응형
반응형
'TIL > 2023' 카테고리의 다른 글
[TIL] 23.07.28 (0) | 2023.07.28 |
---|---|
[TIL] 23.07.26 (0) | 2023.07.26 |
[TIL] 23.07.24 (0) | 2023.07.24 |
[TIL] 23.07.21 (0) | 2023.07.21 |
[TIL] 23.07.20 (2) | 2023.07.20 |