지반침하 레이어 설정 UI 및 포인트 표시 개선

This commit is contained in:
kiminchan
2026-06-26 15:40:21 +09:00
parent 0fe1aa983c
commit e170790e4c
9 changed files with 510 additions and 480 deletions
+14 -3
View File
@@ -29,6 +29,13 @@ const withSiteIdHeaders = (headers: HeadersInit = {}) => ({
const resolveApiUrl = (url: string) =>
url.startsWith('/') ? `${url}` : `${BASE_URL}/${url}`;
const buildInvalidJsonResponseError = (url: string, text: string, contentType?: string | null) => {
const preview = text.trim().slice(0, 200);
const responseType = contentType ? ` (${contentType})` : "";
return new Error(
`JSON 응답이 아닌 데이터를 받았습니다${responseType}: ${url}${preview ? ` - ${preview}` : ""}`,
);
};
const buildRequestError = (
fallbackMessage: string,
status?: number,
@@ -274,11 +281,15 @@ export const getRawJson = async (url: string, init: RequestInit = {}): Promise<a
return null;
}
const trimmed = text.trim();
if (trimmed.startsWith("<")) {
throw buildInvalidJsonResponseError(url, text, res.headers.get("content-type"));
}
try {
return JSON.parse(text);
} catch (error) {
console.error('JSON parsing error:', error);
throw new Error(`Invalid JSON response from server: ${url}`);
} catch {
throw buildInvalidJsonResponseError(url, text, res.headers.get("content-type"));
}
};