Skip to content

Commit 52e16f6

Browse files
author
Tobias Melson
committed
Store error details in a file in case of a panic
1 parent 885baaa commit 52e16f6

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Among others, the following tools are included:
2424

2525
### Customization
2626

27-
You can add a custom tab to the DevToolKit. Create a new file `pages.xml` next to the executable.
27+
You can add a custom tab to the DevToolKit. Create a new file called `pages.xml` in the same directory as the executable.
2828
Here is an example for a simple HTML page with just a single link:
2929

3030
```XML
@@ -45,6 +45,10 @@ Here, `<name>` must be a unique name, `<title>` is the button label, `<tooltip>`
4545
`<icon>` is the [Font Awesome](https://fontawesome.com/v5.14.0/icons?d=gallery&m=free) icon,
4646
and `<body>` is the HTML source of the page.
4747

48+
### Errors
49+
50+
In case of a crash, a stack trace is written to the file `panic.txt` in the same directory as the executable. If you raise a bug report, please attach the content of this file.
51+
4852
## Development
4953

5054
### Build locally

main.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import (
55
"github.com/qaware/dev-tool-kit/backend/core"
66
"github.com/qaware/dev-tool-kit/backend/ui"
77
"github.com/wailsapp/wails"
8+
"io/ioutil"
9+
"os"
10+
"path"
11+
"runtime/debug"
12+
"time"
813
)
914

10-
var version = "3.1.2"
15+
var version = "3.2.0"
1116

1217
func main() {
1318
js := mewn.String("./frontend/build/main.js")
@@ -29,5 +34,26 @@ func main() {
2934
go core.InitUpgrade(version)
3035
go core.CreateAsciiFont()
3136

37+
defer panicRecover()
38+
3239
app.Run()
3340
}
41+
42+
func panicRecover() {
43+
recovered := recover()
44+
if recovered == nil {
45+
return
46+
}
47+
48+
exe, err := os.Executable()
49+
if err != nil {
50+
return
51+
}
52+
dir := path.Dir(exe)
53+
54+
appError, ok := recovered.(error)
55+
if ok {
56+
content := time.Now().String() + "\nVersion: " + version + "\n\n" + appError.Error() + "\n" + string(debug.Stack())
57+
_ = ioutil.WriteFile(path.Join(dir, "panic.txt"), []byte(content), 0777)
58+
}
59+
}

0 commit comments

Comments
 (0)