Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/mcp/src/errors.ts
T
2026-07-08 16:15:37 +02:00

24 lines
618 B
TypeScript

export class McpHttpError extends Error {
readonly status: number;
readonly code: string;
readonly headers: Record<string, string>;
constructor(status: number, code: string, message: string, headers: Record<string, string> = {}) {
super(message);
this.name = "McpHttpError";
this.status = status;
this.code = code;
this.headers = headers;
}
}
export function toToolError(error: unknown): string {
if (error instanceof McpHttpError) {
return `${error.code}: ${error.message}`;
}
if (error instanceof Error) {
return error.message;
}
return "Unknown MCP tool error.";
}