in src/requests/request.ts [195:219]
async function handleResponseNotOk(
response: Response,
url: string,
): Promise<void> {
let message = "";
let errorDetails;
try {
const json = await response.json();
message = json.error.message;
if (json.error.details) {
message += ` ${JSON.stringify(json.error.details)}`;
errorDetails = json.error.details;
}
} catch (e) {
// ignored
}
throw new GoogleGenerativeAIFetchError(
`Error fetching from ${url.toString()}: [${response.status} ${
response.statusText
}] ${message}`,
response.status,
response.statusText,
errorDetails,
);
}