fix: throw an error on panic. (#1540)
* fix: throw an error on panic. * current min go version is go1.13
This commit is contained in:
parent
10c786e52a
commit
b79e0c5adf
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module github.com/golangci/golangci-lint
|
module github.com/golangci/golangci-lint
|
||||||
|
|
||||||
go 1.12
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a
|
4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a
|
||||||
|
@ -91,6 +91,8 @@ func (r *Runner) runLinterSafe(ctx context.Context, lintCtx *linter.Context,
|
|||||||
defer func() {
|
defer func() {
|
||||||
if panicData := recover(); panicData != nil {
|
if panicData := recover(); panicData != nil {
|
||||||
if pe, ok := panicData.(*errorutil.PanicError); ok {
|
if pe, ok := panicData.(*errorutil.PanicError); ok {
|
||||||
|
err = fmt.Errorf("%s: %w", lc.Name(), pe)
|
||||||
|
|
||||||
// Don't print stacktrace from goroutines twice
|
// Don't print stacktrace from goroutines twice
|
||||||
lintCtx.Log.Warnf("Panic: %s: %s", pe, pe.Stack())
|
lintCtx.Log.Warnf("Panic: %s: %s", pe, pe.Stack())
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user