rebuild(stage-2): establish runtime and persistence foundations
This commit is contained in:
@@ -29,7 +29,7 @@ describe("api client", () => {
|
||||
vi.fn().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
error: { code: "unavailable", message: "暂不可用", correlation_id: "abc" },
|
||||
error: { code: "unavailable", message: "暂不可用", request_id: "abc" },
|
||||
}),
|
||||
{ status: 503, headers: { "Content-Type": "application/json" } },
|
||||
),
|
||||
@@ -42,7 +42,7 @@ describe("api client", () => {
|
||||
message: "暂不可用",
|
||||
status: 503,
|
||||
code: "unavailable",
|
||||
correlationId: "abc",
|
||||
requestId: "abc",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ type ApiErrorPayload = {
|
||||
error?: {
|
||||
code?: string;
|
||||
message?: string;
|
||||
correlation_id?: string;
|
||||
request_id?: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ export class ApiError extends Error {
|
||||
message: string,
|
||||
readonly status: number,
|
||||
readonly code: string,
|
||||
readonly correlationId?: string,
|
||||
readonly requestId?: string,
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
payload.error?.message ?? "请求失败,请稍后重试。",
|
||||
response.status,
|
||||
payload.error?.code ?? "request_failed",
|
||||
payload.error?.correlation_id,
|
||||
payload.error?.request_id,
|
||||
);
|
||||
}
|
||||
return payload;
|
||||
|
||||
Reference in New Issue
Block a user