deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
90 lines (89 loc) • 3.34 kB
TypeScript
/**
* @fileoverview Error handlers for specific error types
* This module provides utilities for handling different types of errors.
*/
import { AxiosError } from 'axios';
import { ErrorCategory } from './categories.js';
import { ClassifiedError } from './types.js';
/**
* Error classifier for GraphQL errors
* @param error The error to classify
* @returns The classified error category
* @public
*/
export declare function classifyGraphQLError(error: Error): ErrorCategory;
/**
* Type guard to check if an unknown error is an Error object
* @param error The error to check
* @returns True if the error is an Error instance
* @public
*/
export declare function isError(error: unknown): error is Error;
/**
* Type guard to check if an error contains a specific message substring
* @param error The error to check
* @param substring The substring to search for in the error message
* @returns True if the error is an Error with the specified substring
* @public
*/
export declare function isErrorWithMessage(error: unknown, substring: string): error is Error;
/**
* Checks if an error is an Axios error with specific characteristics
* @param error The error to check
* @param statusCode Optional HTTP status code to match
* @param errorCode Optional Axios error code to match
* @returns True if the error matches the criteria and is an AxiosError, false otherwise
* @public
*/
export declare function isAxiosErrorWithCriteria(error: unknown, statusCode?: number, errorCode?: string): error is AxiosError;
/**
* Extract error messages from GraphQL error response
* @param errors Array of GraphQL error objects
* @returns Formatted error message string
* @public
*/
export declare function extractGraphQLErrorMessages(errors: Array<{
message: string;
}>): string;
/**
* Handle GraphQL-specific errors from Axios responses
* @param error The error to check for GraphQL errors
* @returns A ClassifiedError if a GraphQL error is found, otherwise null
* @public
*/
export declare function handleGraphQLSpecificError(error: unknown): ClassifiedError | null;
/**
* Handle network and connection errors
* @param error The error to check
* @returns A ClassifiedError if a network error is found, otherwise null
* @public
*/
export declare function handleNetworkError(error: unknown): ClassifiedError | null;
/**
* Handle HTTP status-specific errors
* @param error The error to check
* @returns A ClassifiedError if an HTTP status error is found, otherwise null
* @public
*/
export declare function handleHttpStatusError(error: unknown): ClassifiedError | null;
/**
* Check if an error is retriable based on its classification
* @param error The error to check
* @returns True if the error should be retried
* @public
*/
export declare function isRetriableError(error: unknown): boolean;
/**
* Extract Retry-After header from an error response
* @param error The error to extract from
* @returns The Retry-After header value or undefined
* @public
*/
export declare function extractRetryAfterHeader(error: unknown): string | undefined;
/**
* Main error handler that processes different error types in sequence
* @param error The error to handle
* @returns A ClassifiedError appropriate for the error type
* @public
*/
export declare function handleApiError(error: unknown): ClassifiedError;