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/compile.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/compile.go')
-rw-r--r-- | cmd/vartan/compile.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd/vartan/compile.go b/cmd/vartan/compile.go index 3753cd0..f29e972 100644 --- a/cmd/vartan/compile.go +++ b/cmd/vartan/compile.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime/debug" "strings" verr "github.com/nihei9/vartan/error" @@ -46,8 +47,8 @@ func runCompile(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 } @@ -67,7 +68,8 @@ func runCompile(cmd *cobra.Command, args []string) (retErr error) { } } } - fmt.Fprintln(os.Stderr, retErr) + + fmt.Fprintf(os.Stderr, "%v:\n%v", retErr, string(debug.Stack())) } }() |