Skip to content

Commit 076f6b9

Browse files
authored
fix: improve panic management (#3710)
1 parent e394120 commit 076f6b9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: pkg/golinters/goanalysis/runner_action.go

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

0 commit comments

Comments
 (0)