Print stack trace when encountering unexpected panic (#406)

This commit is contained in:
Frederik Ring 2024-04-15 15:12:10 +02:00 committed by GitHub
parent 8b69566291
commit f2ef48803c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,7 @@ package main
import (
"errors"
"fmt"
"runtime/debug"
"github.com/offen/docker-volume-backup/internal/errwrap"
)
@ -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")