diff options
| author | Jeff Carr <[email protected]> | 2025-09-04 00:13:31 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-04 00:13:31 -0500 |
| commit | 33f801ed717dc3edb73c8619d6ea7b4694342437 (patch) | |
| tree | 37e19ef041e2e85ecce8fde230faab681d5e3808 /init.go | |
| parent | 7c2c36f892e6c858954ce205e3136036962dfb33 (diff) | |
finally crapping panic() (maybe. notsure.)
Diffstat (limited to 'init.go')
| -rw-r--r-- | init.go | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -15,6 +15,11 @@ import ( // const Yaxis = 1 // stack things vertically func initNew() { + defer func() { + if r := recover(); r != nil { + crash(r, "watchCallback()") + } + }() log.Log(INFO, "init() has been run") me.counter = 0 @@ -75,7 +80,7 @@ func getGuiVersion() (string, error) { return "", errors.New("debug.ReadBuildInfo() not ok") } if tmp == nil { - return "", errors.New("compiled without go module support") + return "", errors.New("compiled without GO module support") } // log.Println("mod.Path = ", tmp.Path) // log.Println("mod.Main.Path = ", tmp.Main.Path) @@ -173,7 +178,19 @@ func toolkitPanic(pname string) { me.rootNode.LoadToolkit("nocui") } +func crash(r any, what string) { + log.Warn("PANIC ecovered in ", r, what) + UnloadToolkits() + log.Warn("PANIC ecovered in before n.Custom()", r, what) + os.Exit(-1) +} + func watchCallback() { + defer func() { + if r := recover(); r != nil { + crash(r, "watchCallback()") + } + }() log.Log(INFO, "guiChan() START") for { log.Log(CHANGE, "guiChan() select restarted") @@ -237,6 +254,11 @@ func watchCallback() { // that it doesn't matter what happens outside of here // TODO: implement throttling someday func (n *Node) gotUserEvent(a widget.Action) { + defer func() { + if r := recover(); r != nil { + crash(r, "watchCallback()") + } + }() log.Log(CHANGE, "gotUserEvent() received event node =", n.id, n.progname, a.Value) if !n.IsEnabled() { @@ -278,7 +300,16 @@ func (n *Node) gotUserEvent(a widget.Action) { log.Log(CHANGE, "a Custom() function was not set for this widget") return } - go n.Custom() + go something(n) +} + +func something(n *Node) { + defer func() { + if r := recover(); r != nil { + crash(r, "watchCallback()") + } + }() + n.Custom() } // There should only be one of these per application |
