Skip to content

Commit b194ce4

Browse files
committed
fix: include workspace name and log errors in generateAgentRules
Add the workspace folder name to the user-facing error message and log CLI failure details to the output channel when execFileAsync throws. Closes #38 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 6ecd54b commit b194ce4

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/commands/initializeProject.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function initializeProject(): Promise<void> {
4848
try {
4949
rules = await generateAgentRules(status.binaryPath, folder.uri.fsPath);
5050
} catch (error) {
51-
await vscode.window.showErrorMessage(`Failed to run patchloom agent-rules: ${formatError(error)}`);
51+
await vscode.window.showErrorMessage(`Failed to run patchloom agent-rules in ${folder.name}: ${formatError(error)}`);
5252
return;
5353
}
5454

@@ -106,14 +106,19 @@ async function generateAgentRules(binaryPath: string, cwd: string): Promise<stri
106106
const log = getPatchloomLog();
107107
const args = ["agent-rules"];
108108
log?.logCommand(binaryPath, args, cwd);
109-
const { stdout, stderr } = await execFileAsync(binaryPath, args, {
110-
cwd,
111-
timeout: 10_000,
112-
maxBuffer: 1024 * 1024,
113-
windowsHide: true
114-
});
115-
log?.logResult(0, stdout, stderr);
116-
return stdout.endsWith("\n") ? stdout : `${stdout}\n`;
109+
try {
110+
const { stdout, stderr } = await execFileAsync(binaryPath, args, {
111+
cwd,
112+
timeout: 10_000,
113+
maxBuffer: 1024 * 1024,
114+
windowsHide: true
115+
});
116+
log?.logResult(0, stdout, stderr);
117+
return stdout.endsWith("\n") ? stdout : `${stdout}\n`;
118+
} catch (error) {
119+
log?.logResult(1, "", formatError(error));
120+
throw error;
121+
}
117122
}
118123

119124
async function readTextFileIfExists(uri: VSCode.Uri): Promise<string | undefined> {

0 commit comments

Comments
 (0)