/**
* Custom error types for HackerNews MCP Server
*/
/**
* Base error class for API-related errors
*/
export class APIError extends Error {
constructor(
message: string,
public statusCode?: number,
public response?: any,
) {
super(message);
this.name = "APIError";
Error.captureStackTrace(this, this.constructor);
}
}
/**
* Validation error for invalid inputs
*/
export class ValidationError extends Error {
constructor(
message: string,
public errors?: any[],
) {
super(message);
this.name = "ValidationError";
Error.captureStackTrace(this, this.constructor);
}
}
/**
* Rate limit exceeded error
*/
export class RateLimitError extends Error {
constructor(
message = "Rate limit exceeded",
public retryAfter?: number,
) {
super(message);
this.name = "RateLimitError";
Error.captureStackTrace(this, this.constructor);
}
}
/**
* Resource not found error
*/
export class NotFoundError extends Error {
constructor(
message: string,
public resourceType?: string,
public resourceId?: string,
) {
super(message);
this.name = "NotFoundError";
Error.captureStackTrace(this, this.constructor);
}
}