src/debugAdapter: suppress error pop-up for failed watch expression evaluation

Watch expressions are repeated over and over again while the program is running, pausing, continuing, etc, and the result is always displayed and continuously refreshed under WATCH. Unlike other types of evaluations (e.g. in REPL, where one expression is evaluated at a time, and the error can be buried among logging messages), there is no advantage to also showing the same error in a pop-up box.

Fixes #143

Change-Id: I026955980d22e955e4af933bc68256dc320c3f56
GitHub-Last-Rev: 9a524922e55ecbda7179749b8de330385107a319
GitHub-Pull-Request: golang/vscode-go#196
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/236999
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/debugAdapter/goDebug.ts b/src/debugAdapter/goDebug.ts
index 59ae63b..62eafbc 100644
--- a/src/debugAdapter/goDebug.ts
+++ b/src/debugAdapter/goDebug.ts
@@ -15,6 +15,7 @@
 import * as util from 'util';
 import {
 	DebugSession,
+	ErrorDestination,
 	Handles,
 	InitializedEvent,
 	logger,
@@ -1599,9 +1600,18 @@
 				log('EvaluateResponse');
 			},
 			(err) => {
+				let dest: ErrorDestination;
+				// No need to repeatedly show the error pop-up when expressions
+				// are continiously reevaluated in the Watch panel, which
+				// already displays errors.
+				if (args.context === 'watch') {
+					dest = null;
+				} else {
+					dest = ErrorDestination.User;
+				}
 				this.sendErrorResponse(response, 2009, 'Unable to eval expression: "{e}"', {
 					e: err.toString()
-				});
+				}, dest);
 			}
 		);
 	}