improv: error handling

This commit is contained in:
Tomasz Stefaniak 2025-10-09 13:51:50 -07:00
parent 87170203f5
commit 357c9b2bfa
2 changed files with 25 additions and 32 deletions

View file

@ -448,34 +448,24 @@ export class ControlPlaneClient {
prompt: string,
repoUrl: string,
branch?: string,
): Promise<{ id: string } | null> {
): Promise<{ id: string }> {
if (!(await this.isSignedIn())) {
return null;
throw new Error("Not signed in to Continue");
}
try {
const resp = await this.requestAndHandleError("agents/devboxes", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt,
repoUrl,
branch,
}),
});
return (await resp.json()) as { id: string };
} catch (e) {
Logger.error(e, {
context: "control_plane_create_background_agent",
const resp = await this.requestAndHandleError("agents/devboxes", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt,
repoUrl,
branch,
});
return null;
}
}),
});
return (await resp.json()) as { id: string };
}
/**

View file

@ -338,6 +338,12 @@ export class VsCodeMessenger {
// Create the background agent
try {
console.log("Creating background agent with:", {
prompt: prompt.substring(0, 50) + "...",
repoUrl,
branch,
});
const result =
await configHandler.controlPlaneClient.createBackgroundAgent(
prompt,
@ -345,18 +351,15 @@ export class VsCodeMessenger {
branch,
);
if (result) {
vscode.window.showInformationMessage(
`Background agent created successfully! Agent ID: ${result.id}`,
);
} else {
vscode.window.showErrorMessage(
"Failed to create background agent. Make sure you're signed in to Continue.",
);
}
vscode.window.showInformationMessage(
`Background agent created successfully! Agent ID: ${result.id}`,
);
} catch (e) {
console.error("Failed to create background agent:", e);
const errorMessage =
e instanceof Error ? e.message : "Unknown error occurred";
vscode.window.showErrorMessage(
`Error creating background agent: ${e instanceof Error ? e.message : "Unknown error"}`,
`Failed to create background agent: ${errorMessage}`,
);
}
});