Skip to content

Commit

Permalink
Make __brs_err__ virtual so it is greyed out
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-Holbrook committed Jan 8, 2025
1 parent 7d2dfd7 commit f7d9081
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/debugProtocol/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ export enum StopReason {
/**
* Thread stopped because of an error during execution.
*/
RuntimeError = 'RuntimeError'
RuntimeError = 'RuntimeError',
/**
* Thread stopped because of a caught error during execution.
*/
CaughtRuntimeError = 'CaughtRuntimeError'
}
/**
* Only used for serializing/deserializing over the debug protocol. Use `StopReason` in your code.
Expand All @@ -165,7 +169,8 @@ export enum StopReasonCode {
NormalExit = 2,
StopStatement = 3,
Break = 4,
RuntimeError = 5
RuntimeError = 5,
CaughtRuntimeError = 6
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/debugProtocol/client/DebugProtocolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,13 +1018,14 @@ export class DebugProtocolClient {
this.isStopped = true;

let eventName: 'runtime-error' | 'suspend';
if (update.data.stopReason === StopReason.RuntimeError) {
//TODO should caught runtime error remap to runtime error?
if (update.data.stopReason === StopReason.RuntimeError || update.data.stopReason === StopReason.CaughtRuntimeError) {
eventName = 'runtime-error';
} else {
eventName = 'suspend';
}

const isValidStopReason = [StopReason.RuntimeError, StopReason.Break, StopReason.StopStatement].includes(update.data.stopReason);
const isValidStopReason = [StopReason.RuntimeError, StopReason.Break, StopReason.StopStatement, StopReason.CaughtRuntimeError].includes(update.data.stopReason);

if (update instanceof AllThreadsStoppedUpdate && isValidStopReason) {
this.primaryThread = update.data.threadIndex;
Expand Down
9 changes: 5 additions & 4 deletions src/debugSession/BrightScriptDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,14 @@ export class BrightScriptDebugSession extends BaseDebugSession {
response.body.exceptionBreakpointFilters = [{
filter: 'caught',
supportsCondition: true,
//TODO rewrite with the correct variable (`__brs_error__
conditionDescription: '_brserr.rethrown = true',
conditionDescription: '__brs_err__.rethrown = true',
label: 'Caught Exceptions',
description: `Breaks on all errors, even if they're caught later.`,
default: false
}, {
filter: 'uncaught',
supportsCondition: true,
//TODO rewrite with the correct variable (`__brs_error__
conditionDescription: '_brserr.rethrown = true',
conditionDescription: '__brs_err__.rethrown = true',
label: 'Uncaught Exceptions',
description: 'Breaks only on errors that are not handled.',
default: true
Expand Down Expand Up @@ -1560,6 +1558,9 @@ export class BrightScriptDebugSession extends BaseDebugSession {
v.frameId = frameId;
v.type = result.type;
v.presentationHint = result.presentationHint ? { kind: result.presentationHint } : undefined;
if (v.name === '__brs_err__' || v.name === '__brs_errcond__') {
v.presentationHint = { kind: 'virtual' };
}

if (result.children) {
let childVariables = [];
Expand Down

0 comments on commit f7d9081

Please sign in to comment.