Skip to content

Commit 3a792d9

Browse files
committed
internal/lsp: fix panic when logging errors in snapshot.KnownPackages
Fixes #35606 Change-Id: I85eef677ed2e6a971d2955ba97358d26ecf18ac1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/207346 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent 1c71899 commit 3a792d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/lsp/cache/snapshot.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package cache
22

33
import (
44
"context"
5-
"fmt"
65
"os"
76
"sync"
87

98
"golang.org/x/tools/go/analysis"
109
"golang.org/x/tools/internal/lsp/source"
10+
"golang.org/x/tools/internal/lsp/telemetry"
1111
"golang.org/x/tools/internal/span"
1212
"golang.org/x/tools/internal/telemetry/log"
1313
)
@@ -144,14 +144,14 @@ func (s *snapshot) KnownPackages(ctx context.Context) []source.Package {
144144
}
145145
cph, err := s.checkPackageHandle(ctx, pkgID, mode)
146146
if err != nil {
147-
log.Error(ctx, fmt.Sprintf("cph.Check of %v", cph.m.pkgPath), err)
147+
log.Error(ctx, "failed to create CheckPackageHandle", err, telemetry.Package.Of(pkgID))
148148
continue
149149
}
150150
// Check the package now if it's not checked yet.
151151
// TODO(matloob): is this too slow?
152152
pkg, err := cph.check(ctx)
153153
if err != nil {
154-
log.Error(ctx, fmt.Sprintf("cph.Check of %v", cph.m.pkgPath), err)
154+
log.Error(ctx, "failed to check package", err, telemetry.Package.Of(pkgID))
155155
continue
156156
}
157157
results = append(results, pkg)

0 commit comments

Comments
 (0)