Skip to content

Commit 104eeb7

Browse files
committed
Fix error catching not working in Copilot mode
1 parent 512e1b1 commit 104eeb7

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Since v2.1.0, we're keeping a changelog of each version's changes in NeuroPilot.
66

77
Changes between each version before then will not be listed.
88

9+
## 2.2.3
10+
11+
### Fixes
12+
13+
- Fixed error catching not working in Copilot mode.
14+
915
## 2.2.2
1016

1117
### Added features

src/rce.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export interface RceRequest {
4747
* Disposable events
4848
*/
4949
cancelEvents?: vscode.Disposable[]
50+
/**
51+
* The action data associated with this request.
52+
*/
53+
actionData: ActionData;
5054
}
5155

5256
export const cancelRequestAction: RCEAction = {
@@ -103,10 +107,13 @@ export function clearRceRequest(): void {
103107
* Creates a new RCE request and attaches it to NEURO.
104108
* @param prompt The prompt to be displayed in the notification.
105109
* @param callback The callback function to be executed when the request is accepted.
110+
* @param actionData The action data associated with this request.
111+
* @param cancelEvents Optional array of disposables for cancellation events.
106112
*/
107113
export function createRceRequest(
108114
prompt: string,
109115
callback: () => string | undefined,
116+
actionData: ActionData,
110117
cancelEvents?: vscode.Disposable[],
111118
): void {
112119
NEURO.rceRequest = {
@@ -118,6 +125,7 @@ export function createRceRequest(
118125
resolve: () => { },
119126
attachNotification: async () => { },
120127
cancelEvents,
128+
actionData,
121129
};
122130

123131
const promise = new Promise<void>((resolve) => {
@@ -220,9 +228,15 @@ export function acceptRceRequest(): void {
220228

221229
NEURO.client?.sendContext('Vedal has accepted your request.');
222230

223-
const result = NEURO.rceRequest.callback();
224-
if (result)
225-
NEURO.client?.sendContext(result);
231+
try {
232+
const result = NEURO.rceRequest.callback();
233+
if (result)
234+
NEURO.client?.sendContext(result);
235+
} catch (erm: unknown) {
236+
const actionName = NEURO.rceRequest.actionData.name;
237+
notifyOnCaughtException(actionName, erm);
238+
NEURO.client?.sendActionResult(NEURO.rceRequest.actionData.id, true, `An error occured while executing the action "${actionName}". You can retry if you like, but it may be better to ask Vedal to check what's up.`);
239+
}
226240

227241
clearRceRequest();
228242
}
@@ -369,6 +383,7 @@ export async function RCEActionHandler(actionData: ActionData, actionList: Recor
369383
createRceRequest(
370384
prompt,
371385
() => action.handler(actionData),
386+
actionData,
372387
eventArray,
373388
);
374389

0 commit comments

Comments
 (0)