mcp-sqlite-tools
Version:
MCP server for local SQLite database operations
71 lines • 2.15 kB
TypeScript
/**
* Error handling utilities for the SQLite Tools MCP server
*/
import { SqliteErrorCode } from './types.js';
/**
* Custom error class for SQLite operations
*/
export declare class SqliteError extends Error {
readonly code: SqliteErrorCode;
readonly errno?: number;
readonly path?: string;
constructor(message: string, code?: SqliteErrorCode, errno?: number, path?: string);
}
/**
* Custom error class for validation errors
*/
export declare class ValidationError extends Error {
readonly field?: string;
readonly value?: any;
constructor(message: string, field?: string, value?: any);
}
/**
* Custom error class for path security errors
*/
export declare class PathSecurityError extends Error {
readonly attemptedPath: string;
constructor(message: string, attemptedPath: string);
}
/**
* Custom error class for database connection errors
*/
export declare class DatabaseConnectionError extends Error {
readonly databasePath: string;
constructor(message: string, databasePath: string);
}
/**
* Convert better-sqlite3 errors to our custom error types with actionable messages
*/
export declare function convert_sqlite_error(error: any, path?: string): SqliteError;
/**
* Check if an error is a specific SQLite error code
*/
export declare function is_sqlite_error(error: any, code?: SqliteErrorCode): boolean;
/**
* Format error for user-friendly display with structured information
*/
export declare function format_error(error: any): string;
/**
* Helper to create consistent tool responses
*/
export declare function create_tool_response(data: any): {
content: {
type: "text";
text: string;
}[];
};
/**
* Helper to create consistent error responses with structured information
*/
export declare function create_tool_error_response(error: unknown): {
content: {
type: "text";
text: string;
}[];
isError: boolean;
};
/**
* Wrap a function to catch and convert errors
*/
export declare function with_error_handling<T extends any[], R>(fn: (...args: T) => R, context?: string): (...args: T) => R;
//# sourceMappingURL=errors.d.ts.map