fix: bodyError 파싱 중 파싱 불가한 상태일 경우 에러 케이스 수정 #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
EasyCodef SDK 클라이언트
requestProduct()메서드 사용 시 post 요청의 응답이 파싱 불가한 형태로 들어오는 경우, API 응답을 promise resolve 하는 과정에서JSON.parse()가 SyntaxError를 발생, SDK를 이용하는 클라이언트 코드에서 catch 하지 못하는 형태의 에러가 발생하는 케이스가 있습니다.따라서 해당 케이스를 방지하고자
JSON.parse()로직을 try-catch로 감싸 promise 내부에서 에러를 처리하는 방식을 제안합니다.재현 방법:
{ organization: '0004', address: '시화호수전원2길 13-25' }'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>400 Bad Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser sent a request that this server could not understand.<br />\n</p>\n</body></html>\n'위 형태로 response.body가 들어올 경우
JSON.parse()실패