EdgeAIG's picture
download
raw
1.52 kB
import { AISDKError } from './ai-sdk-error';
const name = 'AI_APICallError';
const marker = `vercel.ai.error.${name}`;
const symbol = Symbol.for(marker);
export class APICallError extends AISDKError {
private readonly [symbol] = true; // used in isInstance
readonly url: string;
readonly requestBodyValues: unknown;
readonly statusCode?: number;
readonly responseHeaders?: Record<string, string>;
readonly responseBody?: string;
readonly isRetryable: boolean;
readonly data?: unknown;
constructor({
message,
url,
requestBodyValues,
statusCode,
responseHeaders,
responseBody,
cause,
isRetryable = statusCode != null &&
(statusCode === 408 || // request timeout
statusCode === 409 || // conflict
statusCode === 429 || // too many requests
statusCode >= 500), // server error
data,
}: {
message: string;
url: string;
requestBodyValues: unknown;
statusCode?: number;
responseHeaders?: Record<string, string>;
responseBody?: string;
cause?: unknown;
isRetryable?: boolean;
data?: unknown;
}) {
super({ name, message, cause });
this.url = url;
this.requestBodyValues = requestBodyValues;
this.statusCode = statusCode;
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
this.isRetryable = isRetryable;
this.data = data;
}
static isInstance(error: unknown): error is APICallError {
return AISDKError.hasMarker(error, marker);
}
}

Xet Storage Details

Size:
1.52 kB
·
Xet hash:
6b486808ccb4308a7c84322d6e248e2923c0faf6a145bd3eabe855a278e906f2

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.