wr: common-codes error 메시지 수정
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user