aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debug/debug.go12
-rw-r--r--gomuks.go2
2 files changed, 10 insertions, 4 deletions
diff --git a/debug/debug.go b/debug/debug.go
index 9af3d9d..c6f367e 100644
--- a/debug/debug.go
+++ b/debug/debug.go
@@ -17,6 +17,7 @@
package debug
import (
+ "bytes"
"fmt"
"io"
"io/ioutil"
@@ -67,14 +68,18 @@ const Oops = ` __________
U ||----W |
|| ||`
-func PrettyPanic() {
+func PrettyPanic(panic interface{}) {
fmt.Println(Oops)
fmt.Println("")
fmt.Println("A fatal error has occurred.")
fmt.Println("")
traceFile := fmt.Sprintf("/tmp/gomuks-panic-%s.txt", time.Now().Format("2006-01-02--15-04-05"))
- data := debug.Stack()
- err := ioutil.WriteFile(traceFile, data, 0644)
+
+ var buf bytes.Buffer
+ fmt.Fprintln(&buf, panic)
+ buf.Write(debug.Stack())
+ err := ioutil.WriteFile(traceFile, buf.Bytes(), 0644)
+
if err != nil {
fmt.Println("Saving the stack trace to", traceFile, "failed:")
fmt.Println("--------------------------------------------------------------------------------")
@@ -85,6 +90,7 @@ func PrettyPanic() {
fmt.Println("Please provide the file save error (above) and the stack trace of the original error (below) when filing an issue.")
fmt.Println("")
fmt.Println("--------------------------------------------------------------------------------")
+ fmt.Println(panic)
debug.PrintStack()
fmt.Println("--------------------------------------------------------------------------------")
} else {
diff --git a/gomuks.go b/gomuks.go
index 5edae3a..494f182 100644
--- a/gomuks.go
+++ b/gomuks.go
@@ -117,7 +117,7 @@ func (gmx *Gomuks) Recover() {
if gmx.debugMode {
panic(p)
} else {
- debug.PrettyPanic()
+ debug.PrettyPanic(p)
}
}
}