mirror of
https://github.com/golang/go
synced 2024-11-18 18:54:42 -07:00
internal/lsp: fix panic when logging errors in snapshot.KnownPackages
Fixes golang/go#35606 Change-Id: I85eef677ed2e6a971d2955ba97358d26ecf18ac1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/207346 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
1c71899d35
commit
3a792d9c32
6
internal/lsp/cache/snapshot.go
vendored
6
internal/lsp/cache/snapshot.go
vendored
@ -2,12 +2,12 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"golang.org/x/tools/go/analysis"
|
"golang.org/x/tools/go/analysis"
|
||||||
"golang.org/x/tools/internal/lsp/source"
|
"golang.org/x/tools/internal/lsp/source"
|
||||||
|
"golang.org/x/tools/internal/lsp/telemetry"
|
||||||
"golang.org/x/tools/internal/span"
|
"golang.org/x/tools/internal/span"
|
||||||
"golang.org/x/tools/internal/telemetry/log"
|
"golang.org/x/tools/internal/telemetry/log"
|
||||||
)
|
)
|
||||||
@ -144,14 +144,14 @@ func (s *snapshot) KnownPackages(ctx context.Context) []source.Package {
|
|||||||
}
|
}
|
||||||
cph, err := s.checkPackageHandle(ctx, pkgID, mode)
|
cph, err := s.checkPackageHandle(ctx, pkgID, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, fmt.Sprintf("cph.Check of %v", cph.m.pkgPath), err)
|
log.Error(ctx, "failed to create CheckPackageHandle", err, telemetry.Package.Of(pkgID))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Check the package now if it's not checked yet.
|
// Check the package now if it's not checked yet.
|
||||||
// TODO(matloob): is this too slow?
|
// TODO(matloob): is this too slow?
|
||||||
pkg, err := cph.check(ctx)
|
pkg, err := cph.check(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, fmt.Sprintf("cph.Check of %v", cph.m.pkgPath), err)
|
log.Error(ctx, "failed to check package", err, telemetry.Package.Of(pkgID))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
results = append(results, pkg)
|
results = append(results, pkg)
|
||||||
|
Loading…
Reference in New Issue
Block a user