UNPKG

mcp-image-placeholder

Version:

MCP server for generating placeholder images using placehold.co and picsum.photos

51 lines 1.84 kB
/** * Custom error classes for MCP Image Placeholder server */ export class ImagePlaceholderError extends Error { code; context; constructor(message, code, context) { super(message); this.code = code; this.context = context; this.name = 'ImagePlaceholderError'; // Maintains proper stack trace for where our error was thrown (only available on V8) if (Error.captureStackTrace) { Error.captureStackTrace(this, ImagePlaceholderError); } } } export class ValidationError extends ImagePlaceholderError { constructor(field, value, constraints) { const message = constraints ? `Invalid ${field}: ${value}. ${constraints}` : `Invalid ${field}: ${value}`; super(message, 'VALIDATION_ERROR', { field, value, constraints }); this.name = 'ValidationError'; } } export class ProviderError extends ImagePlaceholderError { constructor(provider, message, context) { super(`Provider "${provider}" error: ${message}`, 'PROVIDER_ERROR', { provider, ...context, }); this.name = 'ProviderError'; } } export class ConfigurationError extends ImagePlaceholderError { constructor(setting, value, expectedFormat) { const message = expectedFormat ? `Configuration error for "${setting}": ${value}. Expected: ${expectedFormat}` : `Configuration error for "${setting}": ${value}`; super(message, 'CONFIGURATION_ERROR', { setting, value, expectedFormat }); this.name = 'ConfigurationError'; } } export class ServerError extends ImagePlaceholderError { constructor(message, context) { super(message, 'SERVER_ERROR', context); this.name = 'ServerError'; } } //# sourceMappingURL=index.js.map