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