Skip to content

Commit a2387ed

Browse files
authored
Suppressing unneeded error message when hovering (#366)
* suppressed the error message of var-create when user is hovering over a non variable * suppressing -var-create error * editing evaluate request test
1 parent 7ad0b83 commit a2387ed

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/gdb/GDBDebugSessionBase.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,11 +1272,21 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
12721272

12731273
this.sendResponse(response);
12741274
} catch (err) {
1275-
this.sendErrorResponse(
1276-
response,
1277-
1,
1278-
err instanceof Error ? err.message : String(err)
1279-
);
1275+
if (
1276+
err instanceof Error &&
1277+
err.message === '-var-create: unable to create variable object'
1278+
) {
1279+
if (args.context === 'hover') {
1280+
response.success = false;
1281+
}
1282+
this.sendResponse(response);
1283+
} else {
1284+
this.sendErrorResponse(
1285+
response,
1286+
1,
1287+
err instanceof Error ? err.message : String(err)
1288+
);
1289+
}
12801290
}
12811291
}
12821292

src/integration-tests/evaluate.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,14 @@ describe('evaluate request', function () {
6868
);
6969
});
7070

71-
it('should reject evaluation of invalid expression', async function () {
72-
const err = await expectRejection(
73-
dc.evaluateRequest({
74-
context: 'repl',
75-
expression: '2 +',
76-
frameId: scope.frame.id,
77-
})
78-
);
71+
it('should send an error when evaluating an invalid expression', async function () {
72+
const err = await dc.evaluateRequest({
73+
context: 'repl',
74+
expression: '2 +',
75+
frameId: scope.frame.id,
76+
});
7977

80-
expect(err.message).eq('-var-create: unable to create variable object');
78+
expect(err.body.result).eq('Error: could not evaluate expression');
8179
});
8280
it('should be able to update the value of a variable named monitor and that variable has local scope', async function () {
8381
const res1 = await dc.evaluateRequest({

0 commit comments

Comments
 (0)