feat: 에러 처리 개선 + 커스텀 확인 모달 + 관리자 테스트
- 에러 코드 기반 한국어 매핑 (8개 코드, parseError 개선) - window.confirm → 커스텀 ConfirmDialog (다크 테마, Promise 기반) - launch URL 파라미터 ticket → token 통일 - 관리자 테스트 27개 추가 (공지사항 12 + 다운로드 6 + 유저 9) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,14 +40,29 @@ async function doFetch(path, options, token) {
|
||||
return fetch(BASE + path, { ...options, headers, credentials: 'include' });
|
||||
}
|
||||
|
||||
/** 에러 코드별 기본 한국어 메시지 */
|
||||
const ERROR_MESSAGES = {
|
||||
bad_request: '잘못된 요청입니다',
|
||||
unauthorized: '로그인이 필요합니다',
|
||||
forbidden: '권한이 없습니다',
|
||||
not_found: '요청한 리소스를 찾을 수 없습니다',
|
||||
conflict: '이미 존재하는 항목입니다',
|
||||
tx_failed: '트랜잭션 처리에 실패했습니다',
|
||||
rate_limited: '요청이 너무 많습니다. 잠시 후 다시 시도해주세요',
|
||||
internal_error: '서버 오류가 발생했습니다',
|
||||
};
|
||||
|
||||
async function parseError(res) {
|
||||
let message = res.statusText;
|
||||
let code;
|
||||
try {
|
||||
const body = await res.json();
|
||||
if (body.error) message = body.error;
|
||||
code = body.error;
|
||||
message = body.message || ERROR_MESSAGES[code] || message;
|
||||
} catch { /* 응답 바디 파싱 실패 시 statusText 사용 */ }
|
||||
const err = new Error(message);
|
||||
err.status = res.status;
|
||||
err.code = code;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user