Эх сурвалжийг харах

Fix debugger watch window freeze caused by missing responses (#781)

MichaelXt 7 сар өмнө
parent
commit
e7b9530a7f

+ 5 - 9
src/debugger/godot3/debug_session.ts

@@ -25,7 +25,6 @@ interface Variable {
 	variable: GodotVariable;
 	index: number;
 	object_id: number;
-	error: string;
 }
 
 export class GodotDebugSession extends LoggingDebugSession {
@@ -126,17 +125,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();
 			}
 		}
 
@@ -405,7 +403,6 @@ export class GodotDebugSession extends LoggingDebugSession {
 			variable: null,
 			index: null,
 			object_id: null,
-			error: null,
 		};
 
 		if (!root) {
@@ -489,8 +486,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) {

+ 5 - 9
src/debugger/godot4/debug_session.ts

@@ -25,7 +25,6 @@ interface Variable {
 	variable: GodotVariable;
 	index: number;
 	object_id: number;
-	error: string;
 }
 
 export class GodotDebugSession extends LoggingDebugSession {
@@ -126,17 +125,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();
 			}
 		}
 
@@ -405,7 +403,6 @@ export class GodotDebugSession extends LoggingDebugSession {
 			variable: null,
 			index: null,
 			object_id: null,
-			error: null,
 		};
 
 		if (!root) {
@@ -489,8 +486,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) {