UNPKG

deepsource-mcp-server

Version:
105 lines (104 loc) 4.69 kB
/** * @fileoverview Error factory for creating classified errors * This module provides utilities for creating standardized error objects. */ import { ErrorCategory } from './categories.js'; import { ClassifiedError } from './types.js'; /** * Create a new classified error with additional metadata * @param message The error message * @param category The error category * @param originalError The original error that caused this error, useful for debugging and error tracing * @param metadata Additional contextual information about the error as key-value pairs * @returns A new classified error with the specified properties * @example * const error = createClassifiedError( * 'Failed to fetch project data', * ErrorCategory.NETWORK, * originalError, * { projectId: '123', endpoint: '/api/projects' } * ); * @public */ export declare function createClassifiedError(message: string, category: ErrorCategory, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create an authentication error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with AUTH category * @public */ export declare function createAuthError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a network error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with NETWORK category * @public */ export declare function createNetworkError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a server error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with SERVER category * @public */ export declare function createServerError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a client error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with CLIENT category * @public */ export declare function createClientError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a timeout error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with TIMEOUT category * @public */ export declare function createTimeoutError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a rate limit error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with RATE_LIMIT category * @public */ export declare function createRateLimitError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a schema error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with SCHEMA category * @public */ export declare function createSchemaError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a not found error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with NOT_FOUND category * @public */ export declare function createNotFoundError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError; /** * Create a format error * @param message The error message * @param originalError The original error that caused this error * @param metadata Additional contextual information about the error * @returns A classified error with FORMAT category * @public */ export declare function createFormatError(message: string, originalError?: unknown, metadata?: Record<string, unknown>): ClassifiedError;