fix(itms-front): api 에러응답 방어적 파싱 — trace/message/error 옵셔널화 (페이지·메뉴 붕괴 방지)
RestApiCallUtil 이 api 에러 응답에서 JSONObject.get("trace")/get("error")/get("message")를
무조건 읽어 필드 부재 시 kong.unirest JSONException → RuntimeException → /error-page/501.do →
페이지 전체(헤더/좌측메뉴 포함) 렌더 붕괴. optString/optInt 로 방어화(정상 파싱 유지, 부재 시 폴백).
검증: 재빌드·배포 후 로그인→메인 200, 좌측메뉴 데이터 렌더, 외부 200 회귀.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
51831b4840
commit
cc6542c7ed
@ -152,25 +152,25 @@ public class RestApiCallUtil
|
||||
// Map 변환처리
|
||||
Map<String, Object> returnMap = null;
|
||||
|
||||
// 비정상처리
|
||||
// 비정상처리
|
||||
if(strFullReturnData.indexOf("status")<0)
|
||||
{
|
||||
String strError = (String)returnObj.get("error");
|
||||
String strMessage = (String)returnObj.get("message");
|
||||
|
||||
// 2026-07-20 방어적 파싱: 필드 부재 시 예외(JSONException) 대신 안전 기본값 → 페이지 전체 붕괴 방지
|
||||
String strMessage = returnObj.optString("message", returnObj.optString("error", "요청 처리 중 오류가 발생했습니다."));
|
||||
|
||||
throw new CustomException("9000", strMessage);
|
||||
}
|
||||
// 정상처리
|
||||
// 정상처리
|
||||
else
|
||||
{
|
||||
// log.info("한번 봅시다 2. => [{}]", returnObj.get("status"));
|
||||
int iReturnStatus = (int)returnObj.get("status");
|
||||
|
||||
int iReturnStatus = returnObj.optInt("status", 200);
|
||||
|
||||
if(iReturnStatus != 200)
|
||||
{
|
||||
String strError = (String)returnObj.get("error");
|
||||
String strErrTrace = (String)returnObj.get("trace");
|
||||
|
||||
// 2026-07-20 trace 옵셔널: 없으면 message/error 로 폴백(kong.unirest get() 은 키부재 시 예외)
|
||||
String strErrTrace = returnObj.optString("trace", returnObj.optString("message", returnObj.optString("error", "요청 처리 중 오류가 발생했습니다.")));
|
||||
|
||||
throw new CustomException("9000", strErrTrace);
|
||||
}
|
||||
else
|
||||
@ -223,13 +223,13 @@ public class RestApiCallUtil
|
||||
JSONObject returnObj = jsonResponse.getBody().getObject();
|
||||
JSONObject returnObjData = new JSONObject();
|
||||
|
||||
int iReturnStatus = (int)returnObj.get("status");
|
||||
|
||||
int iReturnStatus = returnObj.optInt("status", 200);
|
||||
|
||||
if(iReturnStatus != 200)
|
||||
{
|
||||
String strError = (String)returnObj.get("error");
|
||||
String strErrTrace = (String)returnObj.get("trace");
|
||||
|
||||
// 2026-07-20 방어적 파싱: trace 부재 시 message/error 폴백(예외→501 붕괴 방지)
|
||||
String strErrTrace = returnObj.optString("trace", returnObj.optString("message", returnObj.optString("error", "요청 처리 중 오류가 발생했습니다.")));
|
||||
|
||||
throw new CustomException("9000", strErrTrace);
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user