Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Error handling for get_variable() request
Fixes the VSCode watch window freeze due to missing response in case of exception. See related #779
  • Loading branch information
MichaelXt committed Jan 23, 2025
commit 94579ea54f0f6dde8cba3daa8e0af5afbb2218b0
12 changes: 5 additions & 7 deletions src/debugger/godot3/debug_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,16 @@ export class GodotDebugSession extends LoggingDebugSession {
await debug.activeDebugSession.customRequest("scopes", { frameId: 0 });

if (this.all_scopes) {
const variable = this.get_variable(args.expression, null, null, null);

if (variable.error == null) {
try {
const variable = this.get_variable(args.expression, null, null, null);
const parsed_variable = parse_variable(variable.variable);
response.body = {
result: parsed_variable.value,
variablesReference: !is_variable_built_in_type(variable.variable) ? variable.index : 0,
};
} else {
} catch (error) {
response.success = false;
response.message = variable.error;
response.message = error.toString();
}
}

Expand Down Expand Up @@ -489,8 +488,7 @@ export class GodotDebugSession extends LoggingDebugSession {
(x) => x.sanitized.name === propertyName && x.sanitized.scope_path === path,
)?.real;
if (!result.variable) {
result.error = `Could not find: ${propertyName}`;
return result;
throw new Error(`Could not find: ${propertyName}`);
}

if (root.value.entries) {
Expand Down
12 changes: 5 additions & 7 deletions src/debugger/godot4/debug_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,16 @@ export class GodotDebugSession extends LoggingDebugSession {
await debug.activeDebugSession.customRequest("scopes", { frameId: 0 });

if (this.all_scopes) {
const variable = this.get_variable(args.expression, null, null, null);

if (variable.error == null) {
try {
const variable = this.get_variable(args.expression, null, null, null);
const parsed_variable = parse_variable(variable.variable);
response.body = {
result: parsed_variable.value,
variablesReference: !is_variable_built_in_type(variable.variable) ? variable.index : 0,
};
} else {
} catch (error) {
response.success = false;
response.message = variable.error;
response.message = error.toString();
}
}

Expand Down Expand Up @@ -489,8 +488,7 @@ export class GodotDebugSession extends LoggingDebugSession {
(x) => x.sanitized.name === propertyName && x.sanitized.scope_path === path,
)?.real;
if (!result.variable) {
result.error = `Could not find: ${propertyName}`;
return result;
throw new Error(`Could not find: ${propertyName}`);
}

if (root.value.entries) {
Expand Down