Skip to content

Commit

Permalink
Print stack trace when encountering unexpected panic (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 authored Apr 15, 2024
1 parent 8b69566 commit f2ef488
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/backup/run_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"errors"
"fmt"
"runtime/debug"

"github.com/offen/docker-volume-backup/internal/errwrap"
)
Expand All @@ -17,6 +18,7 @@ import (
func runScript(c *Config) (err error) {
defer func() {
if derr := recover(); derr != nil {
fmt.Printf("%s: %s\n", derr, debug.Stack())
asErr, ok := derr.(error)
if ok {
err = errwrap.Wrap(asErr, "unexpected panic running script")
Expand Down

0 comments on commit f2ef488

Please sign in to comment.