Skip to content

Commit

Permalink
cms/scriggo: use the 'runtime.Panic.Error' method to print a panic
Browse files Browse the repository at this point in the history
  • Loading branch information
gazerro committed Jun 28, 2021
1 parent 98f96bb commit 08e8078
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
17 changes: 1 addition & 16 deletions cmd/scriggo/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
17 changes: 1 addition & 16 deletions cmd/scriggo/sources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 08e8078

@gazerro
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cms/scriggo cmd/scriggo: use the 'runtime.Panic.Error' method to print a panic

Please sign in to comment.