@plust/datasleuth
Version:
Build LLM-powered research pipelines and output structured data.
166 lines (165 loc) • 5.58 kB
TypeScript
import { ErrorCode } from './errorCodes.js';
/**
* Base Research Error interface implemented by all specialized error classes
*/
export interface ResearchError extends Error {
/** Error code identifying the specific type of error */
code: ErrorCode;
/** The pipeline step where the error occurred */
step?: string;
/** Additional details about the error for debugging */
details?: Record<string, unknown>;
/** Whether this error should be automatically retried */
retry?: boolean;
/** Suggestions for fixing or working around the error */
suggestions?: string[];
}
/**
* Base implementation for all specialized research error classes
*/
export declare class BaseResearchError extends Error implements ResearchError {
code: ErrorCode;
step?: string;
details?: Record<string, unknown>;
retry: boolean;
suggestions: string[];
constructor(options: {
message: string;
code: ErrorCode;
step?: string;
details?: Record<string, unknown>;
retry?: boolean;
suggestions?: string[];
});
/**
* Creates a formatted error message with details for logging
*/
getFormattedMessage(): string;
}
/**
* Error thrown when there are issues with the research configuration
*/
export declare class ConfigurationError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'>);
}
/**
* Error thrown when input or output validation fails
*/
export declare class ValidationError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'>);
}
/**
* Error thrown when network operations fail
*/
export declare class NetworkError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'> & {
retry?: boolean;
});
}
/**
* Error thrown when external API calls fail
*/
export declare class ApiError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'> & {
retry?: boolean;
statusCode?: number;
});
}
/**
* Error thrown when LLM operations fail
*/
export declare class LLMError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'> & {
retry?: boolean;
});
}
/**
* Error thrown when search operations fail
*/
export declare class SearchError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'> & {
retry?: boolean;
});
}
/**
* Error thrown when content extraction fails
*/
export declare class ExtractionError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'>);
}
/**
* Error thrown when pipeline execution fails
*/
export declare class PipelineError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'>);
}
/**
* Error thrown when processing operations fail
*/
export declare class ProcessingError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'>);
}
/**
* Error thrown when an operation times out
*/
export declare class TimeoutError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'>);
}
/**
* Error thrown when maximum iterations are reached
*/
export declare class MaxIterationsError extends BaseResearchError {
constructor(options: Omit<ConstructorParameters<typeof BaseResearchError>[0], 'code'>);
}
/**
* Type guard to check if an error is a ResearchError
*/
export declare function isResearchError(error: unknown): error is ResearchError;
/**
* Type guard to check if an error is a NetworkError
*/
export declare function isNetworkError(error: unknown): error is NetworkError;
/**
* Type guard to check if an error is an ApiError
*/
export declare function isApiError(error: unknown): error is ApiError;
/**
* Type guard to check if an error is an LLMError
*/
export declare function isLLMError(error: unknown): error is LLMError;
/**
* Type guard to check if an error is a SearchError
*/
export declare function isSearchError(error: unknown): error is SearchError;
/**
* Type guard to check if an error is a ValidationError
*/
export declare function isValidationError(error: unknown): error is ValidationError;
/**
* Type guard to check if an error is a ConfigurationError
*/
export declare function isConfigurationError(error: unknown): error is ConfigurationError;
/**
* Type guard to check if an error is a ProcessingError
*/
export declare function isProcessingError(error: unknown): error is ProcessingError;
/**
* Type guard to check if an error is a TimeoutError
*/
export declare function isTimeoutError(error: unknown): error is TimeoutError;
/**
* Type guard to check if an error is a MaxIterationsError
*/
export declare function isMaxIterationsError(error: unknown): error is MaxIterationsError;
/**
* Type guard to check if an error is an ExtractionError
*/
export declare function isExtractionError(error: unknown): error is ExtractionError;
/**
* Type guard to check if an error is a PipelineError
*/
export declare function isPipelineError(error: unknown): error is PipelineError;
/**
* Type guard to check if an error is retryable
*/
export declare function isRetryableError(error: unknown): boolean;