Skip to content

Commit 30dd25e

Browse files
committed
fix: improve panic management
1 parent 3d2341e commit 30dd25e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/golinters/goanalysis/runner_action.go

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ func (act *action) waitUntilDependingAnalyzersWorked() {
9898
func (act *action) analyzeSafe() {
9999
defer func() {
100100
if p := recover(); p != nil {
101+
// This line allows to display "hidden" panic with analyzers like buildssa.
102+
// Some linters are dependent of sub-analyzers but when a sub-analyzer fails the linter is not aware of that,
103+
// this result to another panic (ex: "interface conversion: interface {} is nil, not *buildssa.SSA").
104+
// This line will create a duplication of the panic message on purpose.
105+
act.r.log.Errorf("panic during analysis: %v, %s", p, string(debug.Stack()))
106+
101107
act.err = errorutil.NewPanicError(fmt.Sprintf("%s: package %q (isInitialPkg: %t, needAnalyzeSource: %t): %s",
102108
act.a.Name, act.pkg.Name, act.isInitialPkg, act.needAnalyzeSource, p), debug.Stack())
103109
}

0 commit comments

Comments
 (0)