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.
This commit is contained in:
Hyang-Ah Hana Kim 2021-04-09 04:03:59 -04:00 committed by GitHub
parent 79e6f7fa90
commit 8b20609227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

@ -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

@ -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)
}