refactor: share provider HTTP error parsing

This commit is contained in:
Peter Steinberger
2026-04-24 19:58:28 +01:00
parent 37d5c34749
commit 2c516fe516
16 changed files with 83 additions and 55 deletions

View File

@@ -9,6 +9,7 @@ import {
sanitizeAndNormalizeEmbedding,
withRemoteHttpResponse,
} from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
import { createProviderHttpError } from "openclaw/plugin-sdk/provider-http";
import type { GeminiEmbeddingClient, GeminiTextEmbeddingRequest } from "./embedding-provider.js";
export type GeminiBatchRequest = {
@@ -179,8 +180,7 @@ async function fetchGeminiBatchStatus(params: {
},
onResponse: async (res) => {
if (!res.ok) {
const text = await res.text();
throw new Error(`gemini batch status failed: ${res.status} ${text}`);
throw await createProviderHttpError(res, "gemini batch status failed");
}
return (await res.json()) as GeminiBatchStatus;
},
@@ -203,8 +203,7 @@ async function fetchGeminiFileContent(params: {
},
onResponse: async (res) => {
if (!res.ok) {
const text = await res.text();
throw new Error(`gemini batch file content failed: ${res.status} ${text}`);
throw await createProviderHttpError(res, "gemini batch file content failed");
}
return await res.text();
},