src/goLanguageServer: show command failure error messages from gopls

When a command execution fails, gopls returns the error details
an error. The LSP client throws an error when receiving the error
response and logs the error details in the server output channel.
But, the error details aren't propagated to VSCode's renderer
process so lost.

Handle the error from the middleware, give an option for user
to see the gopls server trace, and do not rethrow the error
to prevent VSCode from opening another error message popup.

Verified manually. Not sure what kind of automated testing
we want here.

Fixes golang/vscode-go#1237

Change-Id: Ie4cea6337775bab00125fed95266eb4b81423dca
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/300389
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts
index 3a9241e..5ceadd2 100644
--- a/src/goLanguageServer.ts
+++ b/src/goLanguageServer.ts
@@ -22,6 +22,7 @@
 	ConfigurationParams,
 	ConfigurationRequest,
 	ErrorAction,
+	ExecuteCommandSignature,
 	HandleDiagnosticsSignature,
 	InitializeError,
 	Message,
@@ -500,6 +501,20 @@
 				}
 			},
 			middleware: {
+				executeCommand: async (command: string, args: any[], next: ExecuteCommandSignature) => {
+					try {
+						return await next(command, args);
+					} catch (e) {
+						const answer = await vscode.window.showErrorMessage(
+							`Command '${command}' failed: ${e}.`,
+							'Show Trace'
+						);
+						if (answer === 'Show Trace') {
+							serverOutputChannel.show();
+						}
+						return null;
+					}
+				},
 				provideFoldingRanges: async (
 					doc: vscode.TextDocument,
 					context: FoldingContext,