diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-05 21:04:29 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-05 21:04:29 +0900 |
commit | 3d417d5181bd373cbc6e9734ee709c588600a457 (patch) | |
tree | 7bcd522e9267b816f7f8e13bba307f66636672bd /cmd/vartan/parse.go | |
parent | Add --only-parse option to the parse command (diff) | |
download | urubu-3d417d5181bd373cbc6e9734ee709c588600a457.tar.gz urubu-3d417d5181bd373cbc6e9734ee709c588600a457.tar.xz |
Print a stack trace on panic
Diffstat (limited to 'cmd/vartan/parse.go')
-rw-r--r-- | cmd/vartan/parse.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd/vartan/parse.go b/cmd/vartan/parse.go index d5e3d36..61456cf 100644 --- a/cmd/vartan/parse.go +++ b/cmd/vartan/parse.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "runtime/debug" "github.com/nihei9/vartan/driver" "github.com/nihei9/vartan/spec" @@ -37,8 +38,8 @@ func runParse(cmd *cobra.Command, args []string) (retErr error) { if v != nil { err, ok := v.(error) if !ok { - retErr = fmt.Errorf("an unexpected error occurred: %v\n", v) - fmt.Fprintln(os.Stderr, retErr) + retErr = fmt.Errorf("an unexpected error occurred: %v", v) + fmt.Fprintf(os.Stderr, "%v:\n%v", retErr, string(debug.Stack())) return } @@ -46,7 +47,7 @@ func runParse(cmd *cobra.Command, args []string) (retErr error) { } if retErr != nil { - fmt.Fprintln(os.Stderr, retErr) + fmt.Fprintf(os.Stderr, "%v:\n%v", retErr, string(debug.Stack())) } }() |