@mseep/atlas-mcp-server
Version:
A Model Context Protocol (MCP) server for ATLAS, a Neo4j-powered task management system for LLM Agents - implementing a three-tier architecture (Projects, Tasks, Knowledge) to manage complex workflows.
33 lines (32 loc) • 1.26 kB
JavaScript
import { logger } from './logger.js';
import { McpError, BaseErrorCode } from '../types/errors.js';
export const handleOperationError = (error, options) => {
const { context, operation, input } = options;
// If it's already an McpError, just rethrow it
if (error instanceof McpError) {
throw error;
}
// Log the error with consistent format
logger.error(`Error ${operation}`, {
error,
input,
requestId: context.requestContext?.requestId
});
// Convert to McpError with standardized message format
throw new McpError(BaseErrorCode.INTERNAL_ERROR, `Error ${operation}: ${error instanceof Error ? error.message : 'Unknown error'}`);
};
export const handleDatabaseError = (error, errorMap) => {
// If it's already an McpError, rethrow it
if (error instanceof McpError) {
throw error;
}
const errorMessage = error instanceof Error ? error.message : '';
// Check each error pattern and throw corresponding McpError
for (const [pattern, errorFactory] of Object.entries(errorMap)) {
if (errorMessage.includes(pattern)) {
throw errorFactory();
}
}
// If no specific error pattern matches, rethrow the original error
throw error;
};