go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 6f39c23163df336178c914d8b62e66452d345804
parent bdb9b00ff68266b7ed28fa86bc0637c9dbbbcf4f
Author: lash <dev@holbrook.no>
Date:   Sun, 23 Apr 2023 10:41:56 +0100

Remove fixed error for page render

Diffstat:
Mrender/page.go | 13++-----------
Mrender/page_test.go | 13-------------
2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/render/page.go b/render/page.go @@ -20,7 +20,6 @@ type Page struct { sink *string // Content symbol rendered by dynamic size. sizer *Sizer // Process size constraints. err error // Error state to prepend to output. - errConst error // Use this error for display on all errors. } // NewPage creates a new Page object. @@ -56,20 +55,12 @@ func(pg *Page) WithError(err error) *Page { return pg } -// WithFixedError sets an error which will be used for display regardless of which error was set using WithError -func(pg *Page) WithFixedError(err error) *Page { - pg.errConst = err - return pg -} - // Error implements error interface. func(pg *Page) Error() string { if pg.err != nil { - if pg.errConst != nil { - return pg.errConst.Error() - } + return pg.err.Error() } - return pg.err.Error() + return "" } // Usage returns size used by values and menu, and remaining size available diff --git a/render/page_test.go b/render/page_test.go @@ -143,17 +143,4 @@ bar if r != expect { t.Fatalf("expected:\n\t%s\ngot:\n\t%s", expect, r) } - - err = fmt.Errorf("my lumps") - pg = pg.WithFixedError(err) - r, err = pg.Render("foo", 0, ctx) - if err != nil { - t.Fatal(err) - } - expect = `my lumps -bar -0:aiee` - if r != expect { - t.Fatalf("expected:\n\t%s\ngot:\n\t%s", expect, r) - } }