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 { ...@@ -27,6 +27,7 @@ interface RunnerEvent {
label?: string; label?: string;
detail?: string; detail?: string;
message?: string; message?: string;
errorCategory?: string;
content?: string; content?: string;
textDelta?: string; textDelta?: string;
fullText?: string; fullText?: string;
...@@ -70,6 +71,14 @@ function toErrorMessage(error: unknown): string { ...@@ -70,6 +71,14 @@ function toErrorMessage(error: unknown): string {
return String(error); 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> { async function pathExists(targetPath: string): Promise<boolean> {
try { try {
await stat(targetPath); await stat(targetPath);
...@@ -320,12 +329,12 @@ export class ProjectWorkspaceExecutorService { ...@@ -320,12 +329,12 @@ export class ProjectWorkspaceExecutorService {
], spawnOptions); ], spawnOptions);
} }
const finishWithError = (message: string) => { const finishWithError = (message: string, errorCategory?: string) => {
if (settled) { if (settled) {
return; return;
} }
settled = true; settled = true;
reject(new Error(message)); reject(buildWorkspaceExecutionError(message, errorCategory));
}; };
child.stdout.setEncoding("utf8"); child.stdout.setEncoding("utf8");
...@@ -381,7 +390,10 @@ export class ProjectWorkspaceExecutorService { ...@@ -381,7 +390,10 @@ export class ProjectWorkspaceExecutorService {
} }
if (event.type === "error") { 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; 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