diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-09 16:02:17 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-09 16:02:17 -0400 |
| commit | b9f0ad90ec3568cbb1a7a2452d51395377c03a99 (patch) | |
| tree | 8887a96143833845ec479589e903e43c809961ba /listbox.go | |
| parent | a7ec908ebd5e344628717cab874919dfc29cd58c (diff) | |
Steamrolled errors under panic() in Combobox/Listbox.Append()/InsertBefore() because screw Windows being different.
Diffstat (limited to 'listbox.go')
| -rw-r--r-- | listbox.go | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -28,25 +28,23 @@ func NewListbox(multiple bool, items ...string) (l *Listbox) { } // Append adds items to the end of the Listbox's list. -func (l *Listbox) Append(what ...string) (err error) { +// Append will panic if something goes wrong on platforms that do not abort themselves. +func (l *Listbox) Append(what ...string) { l.lock.Lock() defer l.lock.Unlock() if l.created { for i, s := range what { - err := l.sysData.append(s) - if err != nil { - return fmt.Errorf("error adding element %d in Listbox.Append() (%q): %v", i, s, err) - } + l.sysData.append(s) } - return nil + return } l.initItems = append(l.initItems, what...) - return nil } // InsertBefore inserts a new item in the Listbox before the item at the given position. It panics if the given index is out of bounds. -func (l *Listbox) InsertBefore(what string, before int) (err error) { +// InsertBefore will also panic if something goes wrong on platforms that do not abort themselves. +func (l *Listbox) InsertBefore(what string, before int) { l.lock.Lock() defer l.lock.Unlock() @@ -56,7 +54,8 @@ func (l *Listbox) InsertBefore(what string, before int) (err error) { if before < 0 || before >= l.sysData.len() { goto badrange } - return l.sysData.insertBefore(what, before) + l.sysData.insertBefore(what, before) + return } if before < 0 || before >= len(l.initItems) { goto badrange @@ -65,7 +64,7 @@ func (l *Listbox) InsertBefore(what string, before int) (err error) { m = append(m, l.initItems[:before]...) m = append(m, what) l.initItems = append(m, l.initItems[before:]...) - return nil + return badrange: panic(fmt.Errorf("index %d out of range in Listbox.InsertBefore()", before)) } |
