wr: common-codes error 메시지 수정

This commit is contained in:
2026-06-08 11:44:12 +09:00
parent 8c1a976b5b
commit 814365d7de
2 changed files with 31 additions and 3 deletions
+13 -2
View File
@@ -63,7 +63,12 @@ async function fetchJson(url: string, cookieHeader?: string) {
});
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.status}`);
const responseText = await response.text();
throw new Error(
`Failed to fetch ${url}: ${response.status} ${response.statusText}${
responseText ? ` - ${responseText}` : ""
}`
);
}
return response.json();
@@ -200,8 +205,14 @@ export async function GET(request: Request) {
});
} catch (error) {
console.error("Failed to load common codes:", error);
const message =
error instanceof Error ? error.message : "Failed to load common codes";
return NextResponse.json(
{ message: "Failed to load common codes" },
{
message: "Failed to load common codes",
detail:message ,
},
{ status: 500 }
);
}
+18 -1
View File
@@ -379,7 +379,24 @@ export const codeActionExport: (set: any, get:any) => comCodeActions = (set: any
});
if (!response.ok) {
throw new Error(`공통 코드 조회 실패: ${response.status}`);
let errorMessage = `공통 코드 조회 실패: ${response.status}`;
try {
const errorBody = await response.json();
if (errorBody?.detail) {
errorMessage += ` - ${errorBody.detail}`;
} else if (errorBody?.message) {
errorMessage += ` - ${errorBody.message}`;
}
} catch {
const errorText = await response.text();
if (errorText) {
errorMessage += ` - ${errorText}`;
}
}
console.error("initCommonCodes failed:", errorMessage);
throw new Error(errorMessage);
}
const data = await response.json();