-
2021.06.02 기록장TIL 2021. 6. 2. 00:06
To Do
- 리팩터링
- 책 읽기
- 북마크 정리
- 회고 작성
Done
- 북마크 정리
Weekly goal
- 책 읽기
- 블로그 읽기
Feeling
오늘은 RestTemplate 에러를 잡았다.
oauth 구현 시 code를 중복 사용할 시에는 401 에러가 난다.
그래서 해당 예외를 컨트롤하기 위해서 HttpClientErrorException$Unauthorized를 잡거나 따로 잡아야 한다.
restTemplate에는 errorHandler를 붙일 수 있다.
hasError 코드는 response를 살펴보고 에러인지 아닌지를 판단한다. error이면 true
handleError는 에러를 핸들링한다.
if는 정의되지 않은 에러코드일 때 UnknownHttpStatusCodeException를 발생시킨다.
정의된 코드면 series로 판단해서 client인지 server인지 판단을 한다.
https://stackoverflow.com/questions/38093388/spring-resttemplate-exception-handling
Spring Resttemplate exception handling
Below is the code snippet; basically, I am trying to propagate the exception when the error code is anything other than 200. ResponseEntity
https://kwonnam.pe.kr/wiki/springframework/resttemplate
springframework:resttemplate [권남]
kwonnam.pe.kr
spring-projects/spring-framework
Spring Framework. Contribute to spring-projects/spring-framework development by creating an account on GitHub.
github.com
'TIL' 카테고리의 다른 글
2021.06.04~05 기록장 (0) 2021.06.04 2021.06.03 기록장 (0) 2021.06.03 2021.05.31 ~06.01 기록장 (0) 2021.05.31 2021.05.30 기록장 (2) 2021.05.30 2021.05.29 기록장 (0) 2021.05.29