Files
spellforge/Tools/godot-mcp-pro/server/build/utils/errors.js
T
joywayerandClaude Opus 4.8 e65066a8fb chore: 重命名 Tools/godot-mcp-pro-v1.15.1 → Tools/godot-mcp-pro,更新 .mcp.json
- 去掉版本号后缀,路径更稳定(后续更新工具不必再改 .mcp.json)
- .mcp.json 指向新路径 server/build/index.js
- server 依赖已 npm install 就绪;node_modules 由 .gitignore 忽略,未入库

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 15:37:18 +08:00

51 lines
1.7 KiB
JavaScript

export class GodotConnectionError extends Error {
constructor(message) {
super(message);
this.name = "GodotConnectionError";
}
}
export class GodotCommandError extends Error {
code;
data;
constructor(code, message, data) {
super(message);
this.name = "GodotCommandError";
this.code = code;
this.data = data;
}
}
export class TimeoutError extends Error {
constructor(method, timeoutMs) {
super(`Command '${method}' timed out after ${timeoutMs}ms`);
this.name = "TimeoutError";
}
}
export function formatErrorForMcp(error) {
if (error instanceof GodotCommandError) {
let msg = `Godot error (${error.code}): ${error.message}`;
// Surface runtime errors captured at timeout so the agent sees the actual
// cause (a script error that paused the scene) instead of assuming the
// game/connection is dead.
const runtimeErrors = error.data?.runtime_errors;
if (Array.isArray(runtimeErrors) && runtimeErrors.length > 0) {
msg += `\nRuntime errors:\n${runtimeErrors
.map((e) => ` - ${String(e)}`)
.join("\n")}`;
}
if (error.data?.suggestion) {
msg += `\nSuggestion: ${error.data.suggestion}`;
}
return msg;
}
if (error instanceof GodotConnectionError) {
return `Connection error: ${error.message}. Make sure the Godot MCP Pro plugin is enabled in your Godot editor.`;
}
if (error instanceof TimeoutError) {
return error.message;
}
if (error instanceof Error) {
return error.message;
}
return String(error);
}
//# sourceMappingURL=errors.js.map