From 8b206092276a50aaa7edd682fa22d95ca9ba8070 Mon Sep 17 00:00:00 2001 From: Hyang-Ah Hana Kim Date: Fri, 9 Apr 2021 04:03:59 -0400 Subject: [PATCH] dap: suppress error popup for failed evaluation request in repl mode (#2420) It's expected that users enter invalid expressions through DEBUG CONSOLE. Pop up for every error is not pleasant. --- service/dap/server.go | 2 +- service/dap/server_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/service/dap/server.go b/service/dap/server.go index 39e74a82..664944d4 100644 --- a/service/dap/server.go +++ b/service/dap/server.go @@ -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 diff --git a/service/dap/server_test.go b/service/dap/server_test.go index 73cd7e4b..7c5e3265 100644 --- a/service/dap/server_test.go +++ b/service/dap/server_test.go @@ -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) } @@ -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) }