mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:08:26 +00:00
refactor: dedupe provider usage fetch logic and tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { fetchJson } from "./provider-usage.fetch.shared.js";
|
||||
import { buildUsageHttpErrorSnapshot, fetchJson } from "./provider-usage.fetch.shared.js";
|
||||
import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js";
|
||||
import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js";
|
||||
|
||||
@@ -159,13 +159,11 @@ export async function fetchClaudeUsage(
|
||||
}
|
||||
}
|
||||
|
||||
const suffix = message ? `: ${message}` : "";
|
||||
return {
|
||||
return buildUsageHttpErrorSnapshot({
|
||||
provider: "anthropic",
|
||||
displayName: PROVIDER_LABELS.anthropic,
|
||||
windows: [],
|
||||
error: `HTTP ${res.status}${suffix}`,
|
||||
};
|
||||
status: res.status,
|
||||
message,
|
||||
});
|
||||
}
|
||||
|
||||
const data = (await res.json()) as ClaudeUsageResponse;
|
||||
|
||||
Reference in New Issue
Block a user