PANIC: remove almost all panic()s
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
1b8b31a123
commit
20899fc2b4
3
box.go
3
box.go
|
@ -38,9 +38,6 @@ func (n *Node) AddComboBox(title string, s ...string) *Node {
|
||||||
})
|
})
|
||||||
|
|
||||||
box.Append(ecbox, false)
|
box.Append(ecbox, false)
|
||||||
|
|
||||||
// newNode.Dump()
|
|
||||||
// panic("junk")
|
|
||||||
return newNode
|
return newNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@ func (n *Node) AddButton(name string, custom func(*Node)) *Node {
|
||||||
log.Println("gui.AppendButton() Button Clicked. Running custom()")
|
log.Println("gui.AppendButton() Button Clicked. Running custom()")
|
||||||
custom(newNode)
|
custom(newNode)
|
||||||
})
|
})
|
||||||
// panic("AppendButton")
|
|
||||||
// time.Sleep(3 * time.Second)
|
|
||||||
return newNode
|
return newNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
doc.go
5
doc.go
|
@ -64,9 +64,6 @@ GUI Usage
|
||||||
|
|
||||||
Errors
|
Errors
|
||||||
|
|
||||||
Since it is possible for custom Stringer/error interfaces to panic, spew
|
Not sure about errors yet. To early to document them. This is a work in progress.
|
||||||
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.
|
|
||||||
*/
|
*/
|
||||||
package gui
|
package gui
|
||||||
|
|
1
entry.go
1
entry.go
|
@ -14,7 +14,6 @@ func (n *Node) NewLabel(text string) *Node {
|
||||||
// n.Append(ui.NewLabel(text), false)
|
// n.Append(ui.NewLabel(text), false)
|
||||||
newNode := n.makeNode(text, 333, 334)
|
newNode := n.makeNode(text, 333, 334)
|
||||||
newNode.Dump()
|
newNode.Dump()
|
||||||
// panic("node.NewLabel()")
|
|
||||||
|
|
||||||
n.Append(newNode)
|
n.Append(newNode)
|
||||||
return newNode
|
return newNode
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (n *Node) Dump() {
|
||||||
log.Println("gui.Node.Dump() uiButton = ", n.uiButton)
|
log.Println("gui.Node.Dump() uiButton = ", n.uiButton)
|
||||||
log.Println("gui.Node.Dump() uiText = ", n.uiText)
|
log.Println("gui.Node.Dump() uiText = ", n.uiText)
|
||||||
if (n.id == "") {
|
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) {
|
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
|
// TODO: try to find the tab or window and make them if need be
|
||||||
// newNode.uiTab.Append(title, b.UiBox)
|
// newNode.uiTab.Append(title, b.UiBox)
|
||||||
panic("newNode.uiTab")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newNode
|
return newNode
|
||||||
|
@ -244,7 +243,6 @@ func (n *Node) AddHorizontalBreak() *Node {
|
||||||
n.uiBox.Append(tmp, false)
|
n.uiBox.Append(tmp, false)
|
||||||
} else {
|
} else {
|
||||||
n.Dump()
|
n.Dump()
|
||||||
// panic("AddHorizontalBreak")
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
|
|
17
window.go
17
window.go
|
@ -42,9 +42,8 @@ func initNode(title string, x int, y int) *Node {
|
||||||
node.id = id
|
node.id = id
|
||||||
|
|
||||||
if (Data.NodeMap[title] != nil) {
|
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
|
// TODO: just change the 'title' to something unique
|
||||||
// panic(fmt.Sprintf("Duplicate window name = %s\n", title))
|
|
||||||
return Data.NodeMap[title]
|
return Data.NodeMap[title]
|
||||||
}
|
}
|
||||||
Data.NodeMap[title] = &node
|
Data.NodeMap[title] = &node
|
||||||
|
@ -91,11 +90,15 @@ func (n *Node) uiNewWindow(title string, x int, y int) {
|
||||||
w.SetBorderless(false)
|
w.SetBorderless(false)
|
||||||
f := Config.Exit
|
f := Config.Exit
|
||||||
w.OnClosing(func(*ui.Window) bool {
|
w.OnClosing(func(*ui.Window) bool {
|
||||||
if (Config.Debug) {
|
log.Println("RUNNING the ui.Window().OnClosing() function")
|
||||||
log.Println("ui.Window().OnClosing()")
|
|
||||||
}
|
|
||||||
if (f != nil) {
|
if (f != nil) {
|
||||||
f(n)
|
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
|
return true
|
||||||
})
|
})
|
||||||
|
@ -136,7 +139,7 @@ func NewWindow() *Node {
|
||||||
if (uiW != nil) {
|
if (uiW != nil) {
|
||||||
uiW.Show()
|
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]
|
return Data.NodeMap[title]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +159,7 @@ func NewWindow() *Node {
|
||||||
|
|
||||||
n.uiWindow = window
|
n.uiWindow = window
|
||||||
if(n.uiWindow == nil) {
|
if(n.uiWindow == nil) {
|
||||||
panic("node.uiWindow == nil. This should never happen")
|
log.Println("ERROR: node.uiWindow == nil. This should never happen")
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue