Skip to content

Commit e0c9e01

Browse files
committed
Print stacktrace on verbose level 2
1 parent a57857c commit e0c9e01

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"path"
88
"strings"
9+
"runtime/debug"
910
flags "github.com/jessevdk/go-flags"
1011
"github.com/webdevops/go-shell"
1112
"gopkg.in/AlecAivazis/survey.v1"
@@ -122,6 +123,19 @@ func getArgServer(config *sync.SyncConfig, confType string) string {
122123
}
123124

124125
func main() {
126+
defer func() {
127+
if r := recover(); r != nil {
128+
fmt.Println()
129+
if len(opts.Verbose) >= 2 {
130+
fmt.Println(r)
131+
debug.PrintStack()
132+
} else {
133+
fmt.Println(r)
134+
}
135+
os.Exit(255)
136+
}
137+
}()
138+
125139
createArgparser()
126140

127141
argCommand := strings.ToLower(opts.Positional.Command)

0 commit comments

Comments
 (0)