fix: improve panic management (#3710)

This commit is contained in:
Ludovic Fernandez 2023-03-19 23:02:16 +01:00 committed by GitHub
parent e394120f53
commit 076f6b911d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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())
}