@nomyx/assistant
Version:
A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)
24 lines (20 loc) • 595 B
text/typescript
import { AxiosError } from 'axios';
export class VertexProviderError extends Error {
constructor(message: string, public statusCode?: number, public response?: any) {
super(message);
this.name = 'VertexProviderError';
}
}
export function handleVertexError(error: unknown): VertexProviderError {
if (error instanceof VertexProviderError) {
return error;
}
if (error instanceof AxiosError) {
return new VertexProviderError(
error.message,
error.response?.status,
error.response?.data
);
}
return new VertexProviderError(String(error));
}