PANIC: remove almost all panic()s

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-11-04 00:12:48 -05:00
parent 1b8b31a123
commit 20899fc2b4
6 changed files with 13 additions and 21 deletions

3
box.go
View File

@ -38,9 +38,6 @@ func (n *Node) AddComboBox(title string, s ...string) *Node {
})
box.Append(ecbox, false)
// newNode.Dump()
// panic("junk")
return newNode
}

View File

@ -43,8 +43,6 @@ func (n *Node) AddButton(name string, custom func(*Node)) *Node {
log.Println("gui.AppendButton() Button Clicked. Running custom()")
custom(newNode)
})
// panic("AppendButton")
// time.Sleep(3 * time.Second)
return newNode
}

5
doc.go
View File

@ -64,9 +64,6 @@ GUI Usage
Errors
Since it is possible for custom Stringer/error interfaces to panic, spew
detects them and handles them internally by printing the panic information
inline with the output. Since spew is intended to provide deep pretty printing
capabilities on structures, it intentionally does not return any errors.
Not sure about errors yet. To early to document them. This is a work in progress.
*/
package gui

View File

@ -14,7 +14,6 @@ func (n *Node) NewLabel(text string) *Node {
// n.Append(ui.NewLabel(text), false)
newNode := n.makeNode(text, 333, 334)
newNode.Dump()
// panic("node.NewLabel()")
n.Append(newNode)
return newNode

View File

@ -99,7 +99,7 @@ func (n *Node) Dump() {
log.Println("gui.Node.Dump() uiButton = ", n.uiButton)
log.Println("gui.Node.Dump() uiText = ", n.uiText)
if (n.id == "") {
panic("gui.Node.Dump() id == nil")
log.Println("THIS SHOULD NOT HAPPEN: gui.Node.Dump() id == nil")
}
}
@ -228,10 +228,9 @@ func (n *Node) AddTabNode(title string) *Node {
}
if (newNode.uiTab != nil) {
log.Println("wit/gui/ AddTabNode() Something went wrong tab == nil")
log.Println("ERROR: wit/gui/ AddTabNode() Something went wrong tab == nil")
// TODO: try to find the tab or window and make them if need be
// newNode.uiTab.Append(title, b.UiBox)
panic("newNode.uiTab")
}
return newNode
@ -244,7 +243,6 @@ func (n *Node) AddHorizontalBreak() *Node {
n.uiBox.Append(tmp, false)
} else {
n.Dump()
// panic("AddHorizontalBreak")
return nil
}
return n

View File

@ -42,9 +42,8 @@ func initNode(title string, x int, y int) *Node {
node.id = id
if (Data.NodeMap[title] != nil) {
log.Println("Duplicate window name =", title)
log.Println("ERROR: Duplicate window name =", title)
// TODO: just change the 'title' to something unique
// panic(fmt.Sprintf("Duplicate window name = %s\n", title))
return Data.NodeMap[title]
}
Data.NodeMap[title] = &node
@ -91,11 +90,15 @@ func (n *Node) uiNewWindow(title string, x int, y int) {
w.SetBorderless(false)
f := Config.Exit
w.OnClosing(func(*ui.Window) bool {
if (Config.Debug) {
log.Println("ui.Window().OnClosing()")
}
log.Println("RUNNING the ui.Window().OnClosing() function")
if (f != nil) {
f(n)
} else {
n.Dump()
log.Println("gui.uiWindow().OnClosing() NOT SURE WHAT TO DO HERE")
// TODO: always do this here? // by default delete the node?
name := n.Name
delete(Data.NodeMap, name)
}
return true
})
@ -136,7 +139,7 @@ func NewWindow() *Node {
if (uiW != nil) {
uiW.Show()
}
panic("check here to see if window is really alive")
log.Println("PROBABLY BAD ERROR: check here to see if window is really alive")
return Data.NodeMap[title]
}
@ -156,7 +159,7 @@ func NewWindow() *Node {
n.uiWindow = window
if(n.uiWindow == nil) {
panic("node.uiWindow == nil. This should never happen")
log.Println("ERROR: node.uiWindow == nil. This should never happen")
}
return n
}