Skip to content

Commit

Permalink
dap: suppress error popup for failed evaluation request in repl mode (#…
Browse files Browse the repository at this point in the history
…2420)

It's expected that users enter invalid expressions through DEBUG
CONSOLE. Pop up for every error is not pleasant.
  • Loading branch information
hyangah authored Apr 9, 2021
1 parent 79e6f7f commit 8b20609
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion service/dap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ func (s *Server) convertVariableWithOpts(v *proc.Variable, qualifiedNameOrExpr s
// variables, so consider also adding the following:
// -- print {expression} - return the result as a string like from dlv cli
func (s *Server) onEvaluateRequest(request *dap.EvaluateRequest) {
showErrorToUser := request.Arguments.Context != "watch"
showErrorToUser := request.Arguments.Context != "watch" && request.Arguments.Context != "repl"
if s.debugger == nil {
s.sendErrorResponseWithOpts(request.Request, UnableToEvaluateExpression, "Unable to evaluate expression", "debugger is nil", showErrorToUser)
return
Expand Down
4 changes: 2 additions & 2 deletions service/dap/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func TestLaunchStopOnEntry(t *testing.T) {

// 10 >> evaluate, << error
client.EvaluateRequest("foo", 0 /*no frame specified*/, "repl")
erResp := client.ExpectVisibleErrorResponse(t)
erResp := client.ExpectErrorResponse(t)
if erResp.Seq != 0 || erResp.RequestSeq != 10 || erResp.Body.Error.Id != 2009 {
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=10 Id=2009", erResp)
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestAttachStopOnEntry(t *testing.T) {

// 10 >> evaluate, << error
client.EvaluateRequest("foo", 0 /*no frame specified*/, "repl")
erResp := client.ExpectVisibleErrorResponse(t)
erResp := client.ExpectErrorResponse(t)
if erResp.Seq != 0 || erResp.RequestSeq != 10 || erResp.Body.Error.Id != 2009 {
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=10 Id=2009", erResp)
}
Expand Down

0 comments on commit 8b20609

Please sign in to comment.