File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,9 @@ func main() {
111111 os .Exit (0 )
112112 }
113113
114+ // function used to save panic to a file (WIP)
115+ defer panicToFile ()
116+
114117 // Launch main loop in a goroutine
115118 go loop ()
116119
@@ -148,6 +151,24 @@ func main() {
148151 Systray .Start ()
149152}
150153
154+ func panicToFile () {
155+ if r := recover (); r != nil {
156+ fileName := "crashreport_" + time .Now ().Format ("20060102150405" ) + ".txt"
157+ currDir , err := osext .ExecutableFolder ()
158+ if err != nil {
159+ panic (err )
160+ }
161+
162+ crashreport := []byte ("stacktrace from panic: \n " + string (debug .Stack ()))
163+
164+ err = ioutil .WriteFile (filepath .Join (currDir , fileName ), crashreport , 0644 )
165+ if err != nil {
166+ panic (err )
167+ }
168+ panic (r )
169+ }
170+ }
171+
151172func copyExe (from , to string ) error {
152173 data , err := ioutil .ReadFile (from )
153174 if err != nil {
You can’t perform that action at this time.
0 commit comments