From f960932fa6205c800e303dc4b55594979126133d Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Thu, 7 Aug 2014 15:33:29 -0600 Subject: [PATCH] log smudge errors --- commands/command_smudge.go | 2 +- commands/commands.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/commands/command_smudge.go b/commands/command_smudge.go index 7ec0fa0c..5038dfd1 100644 --- a/commands/command_smudge.go +++ b/commands/command_smudge.go @@ -53,7 +53,7 @@ func smudgeCommand(cmd *cobra.Command, args []string) { if err != nil { ptr.Encode(os.Stdout) - Error("Error accessing media: %s (%s)", filename, ptr.Oid) + LoggedError(err, "Error accessing media: %s (%s)", filename, ptr.Oid) } } diff --git a/commands/commands.go b/commands/commands.go index b07ae43d..0e700f58 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -59,15 +59,21 @@ func Debug(format string, args ...interface{}) { log.Printf(format, args...) } -// Panic prints a formatted message, and writes a stack trace for the error to -// a log file before exiting. -func Panic(err error, format string, args ...interface{}) { +// LoggedError prints a formatted message to Stderr and writes a stack trace for +// the error to a log file without exiting. +func LoggedError(err error, format string, args ...interface{}) { Error(format, args...) file := handlePanic(err) if len(file) > 0 { fmt.Fprintf(os.Stderr, "\nErrors logged to %s.\nUse `git media logs last` to view the log.\n", file) } +} + +// Panic prints a formatted message, and writes a stack trace for the error to +// a log file before exiting. +func Panic(err error, format string, args ...interface{}) { + LoggedError(err, format, args...) os.Exit(2) }