From 357c9b2bfa463a46980284dfd77cfb8e5d5607d8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 9 Oct 2025 13:51:50 -0700 Subject: [PATCH] improv: error handling --- core/control-plane/client.ts | 34 +++++++------------ .../vscode/src/extension/VsCodeMessenger.ts | 23 +++++++------ 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 0cb51d468..83eaa228b 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -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 }; } /** diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 409f69dc7..98a0e5e06 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -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}`, ); } });