@toolprint/hypertool-mcp
Version:
HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers
149 lines • 5.73 kB
TypeScript
/**
* Custom error classes and factory functions for persona operations
*
* This module provides a comprehensive error handling system for the persona
* content pack system, including typed error codes, detailed error messages,
* and actionable suggestions for resolution.
*
* @fileoverview Persona system error handling and custom error types
*/
import { PersonaErrorCode, type PersonaErrorInterface } from "./types.js";
/**
* Base persona error class
*
* Custom error class for persona operations that includes error codes,
* additional details, and actionable suggestions for resolution.
*/
export declare class PersonaError extends Error implements PersonaErrorInterface {
/** Specific error code for programmatic handling */
readonly code: PersonaErrorCode;
/** Additional error details */
readonly details: Record<string, any>;
/** Actionable suggestions for resolving the error */
readonly suggestions: string[];
/** Whether the error is recoverable */
readonly recoverable: boolean;
constructor(code: PersonaErrorCode, message: string, options?: {
details?: Record<string, any>;
suggestions?: string[];
recoverable?: boolean;
cause?: Error;
});
/**
* Create a formatted error message that includes suggestions
*/
getFormattedMessage(): string;
/**
* Serialize error to JSON for logging or transmission
*/
toJSON(): Record<string, any>;
}
/**
* Discovery-specific persona error
*/
export declare class PersonaDiscoveryError extends PersonaError {
constructor(code: PersonaErrorCode.PERSONA_NOT_FOUND | PersonaErrorCode.PERMISSION_DENIED | PersonaErrorCode.FILE_SYSTEM_ERROR, message: string, options?: {
details?: Record<string, any>;
suggestions?: string[];
recoverable?: boolean;
cause?: Error;
});
}
/**
* Validation-specific persona error
*/
export declare class PersonaValidationError extends PersonaError {
constructor(code: PersonaErrorCode.INVALID_SCHEMA | PersonaErrorCode.VALIDATION_FAILED | PersonaErrorCode.YAML_PARSE_ERROR | PersonaErrorCode.DUPLICATE_PERSONA_NAME, message: string, options?: {
details?: Record<string, any>;
suggestions?: string[];
recoverable?: boolean;
cause?: Error;
});
}
/**
* Activation-specific persona error
*/
export declare class PersonaActivationError extends PersonaError {
constructor(code: PersonaErrorCode.ACTIVATION_FAILED | PersonaErrorCode.TOOLSET_NOT_FOUND | PersonaErrorCode.TOOL_RESOLUTION_FAILED | PersonaErrorCode.MCP_CONFIG_CONFLICT, message: string, options?: {
details?: Record<string, any>;
suggestions?: string[];
recoverable?: boolean;
cause?: Error;
});
}
/**
* Runtime-specific persona error
*/
export declare class PersonaRuntimeError extends PersonaError {
constructor(code: PersonaErrorCode.FILE_SYSTEM_ERROR | PersonaErrorCode.ARCHIVE_EXTRACTION_FAILED, message: string, options?: {
details?: Record<string, any>;
suggestions?: string[];
recoverable?: boolean;
cause?: Error;
});
}
/**
* Create a persona not found error
*/
export declare function createPersonaNotFoundError(personaName: string, searchPaths?: string[]): PersonaDiscoveryError;
/**
* Create a schema validation error
*/
export declare function createSchemaValidationError(field: string, value: any, expectedType: string, cause?: Error): PersonaValidationError;
/**
* Create a YAML parsing error
*/
export declare function createYamlParseError(filePath: string, line?: number, column?: number, cause?: Error): PersonaValidationError;
/**
* Create a tool resolution error
*/
export declare function createToolResolutionError(toolIds: string[], unavailableTools: string[]): PersonaActivationError;
/**
* Create a toolset not found error
*/
export declare function createToolsetNotFoundError(toolsetName: string, availableToolsets: string[]): PersonaActivationError;
/**
* Create a file system permission error
*/
export declare function createPermissionError(operation: string, path: string, cause?: Error): PersonaDiscoveryError;
/**
* Create a file system error
*/
export declare function createFileSystemError(operation: string, path: string, cause?: Error): PersonaRuntimeError;
/**
* Create an MCP configuration conflict error
*/
export declare function createMcpConfigConflictError(conflictingKeys: string[], personaName: string): PersonaActivationError;
/**
* Create a duplicate persona name error
*/
export declare function createDuplicatePersonaNameError(personaName: string, existingPaths: string[]): PersonaValidationError;
/**
* Create an activation failed error
*/
export declare function createActivationFailedError(personaName: string, reason: string, cause?: Error): PersonaActivationError;
/**
* Create an archive extraction error
*/
export declare function createArchiveExtractionError(archivePath: string, cause?: Error): PersonaRuntimeError;
/**
* Check if an error is a PersonaError
*/
export declare function isPersonaError(error: any): error is PersonaError;
/**
* Check if a PersonaError is recoverable
*/
export declare function isRecoverableError(error: PersonaError): boolean;
/**
* Extract error code from any error (returns undefined for non-PersonaErrors)
*/
export declare function getErrorCode(error: any): PersonaErrorCode | undefined;
/**
* Format an error for user-friendly display
*/
export declare function formatErrorForUser(error: PersonaError): string;
/**
* Create a summary of multiple errors for batch operations
*/
export declare function createErrorSummary(errors: PersonaError[]): string;
//# sourceMappingURL=errors.d.ts.map