Panic on not existing screen since it makes no sense to return values.

This commit is contained in:
Andrey Parhomenko 2023-10-03 13:15:48 +03:00
parent 0471ea91c7
commit 05844d2bc0
2 changed files with 3 additions and 8 deletions

View file

@ -169,7 +169,7 @@ func (af ActionFunc) Act(c *Context) {
} }
// Changes screen of user to the Id one. // Changes screen of user to the Id one.
func (c *Context) Go(pth Path, args ...any) error { func (c *Context) Go(pth Path, args ...any) {
if pth == "-" { if pth == "-" {
pth = c.PrevPath() pth = c.PrevPath()
} }
@ -180,7 +180,7 @@ func (c *Context) Go(pth Path, args ...any) error {
} }
if !c.PathExist(pth) { if !c.PathExist(pth) {
return ScreenNotExistErr panic(ScreenNotExistErr)
} }
c.prevPath = c.path c.prevPath = c.path
c.path = pth c.path = pth
@ -193,8 +193,6 @@ func (c *Context) Go(pth Path, args ...any) error {
} else { } else {
panic("no widget defined for the screen") panic("no widget defined for the screen")
} }
return nil
} }
func (c *Context) PathExist(pth Path) bool { func (c *Context) PathExist(pth Path) bool {

View file

@ -11,10 +11,7 @@ type ScreenGo struct {
} }
func (sc ScreenGo) Act(c *Context) { func (sc ScreenGo) Act(c *Context) {
err := c.Go(sc.Path, sc.Args...) c.Go(sc.Path, sc.Args...)
if err != nil {
panic(err)
}
} }
// The same as Act. // The same as Act.