internal/lsp: log errors for compute fix edits instead of returning

Fixes golang/go#40260

Change-Id: I69032b8cd6b32a262ecd3bb746ef6d1722966a51
Reviewed-on: https://go-review.googlesource.com/c/tools/+/243238
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/code_action.go b/internal/lsp/code_action.go
index e433630..618b0f9 100644
--- a/internal/lsp/code_action.go
+++ b/internal/lsp/code_action.go
@@ -82,7 +82,7 @@
 		if wantQuickFixes := wanted[protocol.QuickFix] && len(diagnostics) > 0; wantQuickFixes || wanted[protocol.SourceOrganizeImports] {
 			importEdits, importEditsPerFix, err := source.AllImportsFixes(ctx, snapshot, fh)
 			if err != nil {
-				return nil, err
+				event.Error(ctx, "imports fixes", err, tag.File.Of(fh.URI().Filename()))
 			}
 			// Separate this into a set of codeActions per diagnostic, where
 			// each action is the addition, removal, or renaming of one import.
diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go
index 2f3dab7..5823a6e 100644
--- a/internal/lsp/source/format.go
+++ b/internal/lsp/source/format.go
@@ -8,6 +8,7 @@
 import (
 	"bytes"
 	"context"
+	"fmt"
 	"go/ast"
 	"go/format"
 	"go/parser"
@@ -18,7 +19,6 @@
 	"golang.org/x/tools/internal/imports"
 	"golang.org/x/tools/internal/lsp/diff"
 	"golang.org/x/tools/internal/lsp/protocol"
-	errors "golang.org/x/xerrors"
 )
 
 // Format formats a file with a given range.
@@ -95,7 +95,7 @@
 		allFixEdits, editsPerFix, err = computeImportEdits(ctx, snapshot.View(), pgh, opts)
 		return err
 	}); err != nil {
-		return nil, nil, errors.Errorf("computing fix edits: %v", err)
+		return nil, nil, fmt.Errorf("AllImportsFixes: %v", err)
 	}
 	return allFixEdits, editsPerFix, nil
 }