Skip to content

Commit

Permalink
fix: improve panic management (#3710)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Mar 19, 2023
1 parent e394120 commit 076f6b9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/golinters/goanalysis/runner_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ func (act *action) waitUntilDependingAnalyzersWorked() {
func (act *action) analyzeSafe() {
defer func() {
if p := recover(); p != nil {
if !act.isroot {
// This line allows to display "hidden" panic with analyzers like buildssa.
// Some linters are dependent of sub-analyzers but when a sub-analyzer fails the linter is not aware of that,
// this results to another panic (ex: "interface conversion: interface {} is nil, not *buildssa.SSA").
act.r.log.Errorf("%s: panic during analysis: %v, %s", act.a.Name, p, string(debug.Stack()))
}

act.err = errorutil.NewPanicError(fmt.Sprintf("%s: package %q (isInitialPkg: %t, needAnalyzeSource: %t): %s",
act.a.Name, act.pkg.Name, act.isInitialPkg, act.needAnalyzeSource, p), debug.Stack())
}
Expand Down

0 comments on commit 076f6b9

Please sign in to comment.