Commit 93078b84 authored by AI-甘富林's avatar AI-甘富林

fix(desktop): preserve workspace execution error categories

Keep workspace runner errorCategory metadata on propagated execution failures so desktop diagnostics can distinguish failure types.
Co-Authored-By: 's avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent 61fd84f1
......@@ -27,6 +27,7 @@ interface RunnerEvent {
label?: string;
detail?: string;
message?: string;
errorCategory?: string;
content?: string;
textDelta?: string;
fullText?: string;
......@@ -70,6 +71,14 @@ function toErrorMessage(error: unknown): string {
return String(error);
}
function buildWorkspaceExecutionError(message: string, errorCategory?: string): Error & { errorCategory?: string } {
const error = new Error(message) as Error & { errorCategory?: string };
if (errorCategory) {
error.errorCategory = errorCategory;
}
return error;
}
async function pathExists(targetPath: string): Promise<boolean> {
try {
await stat(targetPath);
......@@ -320,12 +329,12 @@ export class ProjectWorkspaceExecutorService {
], spawnOptions);
}
const finishWithError = (message: string) => {
const finishWithError = (message: string, errorCategory?: string) => {
if (settled) {
return;
}
settled = true;
reject(new Error(message));
reject(buildWorkspaceExecutionError(message, errorCategory));
};
child.stdout.setEncoding("utf8");
......@@ -381,7 +390,10 @@ export class ProjectWorkspaceExecutorService {
}
if (event.type === "error") {
finishWithError(event.message?.trim() || "Project workspace execution failed.");
finishWithError(
event.message?.trim() || "Project workspace execution failed.",
typeof event.errorCategory === "string" ? event.errorCategory.trim() || undefined : undefined
);
return;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment