export class MCPError extends Error {
constructor(message: string, public code?: string) {
super(message);
this.name = "MCPError";
}
}
export class OpenAIError extends MCPError {
constructor(message: string, public statusCode?: number) {
super(message, "OPENAI_ERROR");
this.name = "OpenAIError";
}
}
export class ValidationError extends MCPError {
constructor(message: string) {
super(message, "VALIDATION_ERROR");
this.name = "ValidationError";
}
}
export class ConfigurationError extends MCPError {
constructor(message: string) {
super(message, "CONFIGURATION_ERROR");
this.name = "ConfigurationError";
}
}
export function formatError(error: unknown): string {
if (error instanceof Error) {
return error.message;
}
return String(error);
}