From 05844d2bc027f619ae60bc47df2b9d49f2810d90 Mon Sep 17 00:00:00 2001 From: surdeus Date: Tue, 3 Oct 2023 13:15:48 +0300 Subject: [PATCH] Panic on not existing screen since it makes no sense to return values. --- tg/context.go | 6 ++---- tg/screen.go | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tg/context.go b/tg/context.go index 9003ae0..ed82f3a 100644 --- a/tg/context.go +++ b/tg/context.go @@ -169,7 +169,7 @@ func (af ActionFunc) Act(c *Context) { } // 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 == "-" { pth = c.PrevPath() } @@ -180,7 +180,7 @@ func (c *Context) Go(pth Path, args ...any) error { } if !c.PathExist(pth) { - return ScreenNotExistErr + panic(ScreenNotExistErr) } c.prevPath = c.path c.path = pth @@ -193,8 +193,6 @@ func (c *Context) Go(pth Path, args ...any) error { } else { panic("no widget defined for the screen") } - - return nil } func (c *Context) PathExist(pth Path) bool { diff --git a/tg/screen.go b/tg/screen.go index 3db33d8..bafb3ba 100644 --- a/tg/screen.go +++ b/tg/screen.go @@ -11,10 +11,7 @@ type ScreenGo struct { } func (sc ScreenGo) Act(c *Context) { - err := c.Go(sc.Path, sc.Args...) - if err != nil { - panic(err) - } + c.Go(sc.Path, sc.Args...) } // The same as Act.