vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

Prompt two same error messages in the right corner

Open ZhengJun003 opened this issue 5 years ago • 1 comments

Environment

  • Operating System: Win10/Mac/Linux
  • JDK version: 11.0.7/13.0.2/14.0.2
  • Visual Studio Code version: 1.47.2
  • Java extension version: 0.64.1
  • Java Debugger extension version: 0.27.0

Steps To Reproduce

  1. Open project 25.restartFrame in vscode.
  2. Set breakpoint: Person.java line 28
  3. Press F5 to start debug.
  4. The program stopped at the Person.java line 28
  5. Open the debug view, find the call stack of current breakpoint
  6. Right click the HelloWorld$1.run(), choose Restart Frame.
Current Result

image

ZhengJun003 avatar Jul 17 '20 09:07 ZhengJun003

At RestartFrameHandler.java#L73:

context.getProtocolServer().sendEvent(new Events.UserNotificationEvent(NotificationType.ERROR, "Current stack frame doesn't support restart."));
throw AdapterUtils.createCompletionException("Current stack frame doesn't support restart.", ErrorCode.RESTARTFRAME_FAILURE);

The first line sends an "event" message (with "Source: Debugger for Java (Extension)"). The second line throws an exception which is handled at ProtocolServer.java#L128, which becomes a "response" message containing an error.

I could fix this, but I don't know which error handling strategy is correct.

Option A

Replace the second line with:

return CompletableFuture.completedFuture(response);

I'm not sure what response is and if completing the future with it is appropriate. Also this would skip a call to logger.log() in ProtocolServer (which might be okay).

Option B

Remove the first line.

The downside here is that the popup wouldn't look as good (it wouldn't have "Source: Debugger for Java (Extension)").

sbj42 avatar Mar 18 '22 00:03 sbj42