From 08e8078303dda62a1c6796f9195b3104b4859fd0 Mon Sep 17 00:00:00 2001 From: Marco Gazerro Date: Mon, 28 Jun 2021 18:32:13 +0200 Subject: [PATCH] cms/scriggo: use the 'runtime.Panic.Error' method to print a panic --- cmd/scriggo/run.go | 17 +---------------- cmd/scriggo/sources.go | 17 +---------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/cmd/scriggo/run.go b/cmd/scriggo/run.go index 2a893d42e..a9be9555a 100644 --- a/cmd/scriggo/run.go +++ b/cmd/scriggo/run.go @@ -24,21 +24,6 @@ const usage = "usage: %s [-S] filename\n" var packages scriggo.Packages -func renderPanics(p *runtime.Panic) string { - var msg string - for ; p != nil; p = p.Next() { - msg = "\n" + msg - if p.Recovered() { - msg = " [recovered]" + msg - } - msg = p.String() + msg - if p.Next() != nil { - msg = "\tpanic: " + msg - } - } - return msg -} - func run() { var asm = flag.Bool("S", false, "print assembly listing") @@ -87,7 +72,7 @@ func run() { code, err := program.Run(nil) if err != nil { if p, ok := err.(*runtime.Panic); ok { - panic(renderPanics(p)) + panic(p) } if err == context.DeadlineExceeded { err = errors.New("process took too long") diff --git a/cmd/scriggo/sources.go b/cmd/scriggo/sources.go index b35a6239c..1f8950c78 100644 --- a/cmd/scriggo/sources.go +++ b/cmd/scriggo/sources.go @@ -2169,21 +2169,6 @@ const usage = "usage: %s [-S] filename\n" var packages scriggo.Packages -func renderPanics(p *runtime.Panic) string { - var msg string - for ; p != nil; p = p.Next() { - msg = "\n" + msg - if p.Recovered() { - msg = " [recovered]" + msg - } - msg = p.String() + msg - if p.Next() != nil { - msg = "\tpanic: " + msg - } - } - return msg -} - func run() { var asm = flag.Bool("S", false, "print assembly listing") @@ -2232,7 +2217,7 @@ func run() { code, err := program.Run(nil) if err != nil { if p, ok := err.(*runtime.Panic); ok { - panic(renderPanics(p)) + panic(p) } if err == context.DeadlineExceeded { err = errors.New("process took too long")