summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2021-11-04 00:12:48 -0500
committerJeff Carr <[email protected]>2021-11-04 00:12:48 -0500
commitae7a69b636bc145745ed8e2b30ab2adba166be74 (patch)
treed40da36b80dac68c6df71af4d2f6ccb54e4d75e2
parent8236be92dc72c2b443dc6ccfc2c2f6877af22afa (diff)
PANIC: remove almost all panic()s
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--box.go3
-rw-r--r--button.go2
-rw-r--r--doc.go5
-rw-r--r--entry.go1
-rw-r--r--new-structs.go6
-rw-r--r--window.go17
6 files changed, 13 insertions, 21 deletions
diff --git a/box.go b/box.go
index 5953f54..65a8d39 100644
--- a/box.go
+++ b/box.go
@@ -38,9 +38,6 @@ func (n *Node) AddComboBox(title string, s ...string) *Node {
})
box.Append(ecbox, false)
-
- // newNode.Dump()
- // panic("junk")
return newNode
}
diff --git a/button.go b/button.go
index c1c1c73..ef73f73 100644
--- a/button.go
+++ b/button.go
@@ -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
}
diff --git a/doc.go b/doc.go
index 2b324c9..3f8bc64 100644
--- a/doc.go
+++ b/doc.go
@@ -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
diff --git a/entry.go b/entry.go
index 05db849..d215cd2 100644
--- a/entry.go
+++ b/entry.go
@@ -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
diff --git a/new-structs.go b/new-structs.go
index 62f826c..65b964f 100644
--- a/new-structs.go
+++ b/new-structs.go
@@ -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
diff --git a/window.go b/window.go
index f22e614..eb39e87 100644
--- a/window.go
+++ b/window.go
@@ -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
}