From: early Date: Thu, 7 Nov 2024 02:31:33 +0000 (-0700) Subject: do a better job propagating errors between components X-Git-Url: https://git.earlybird.gay/?a=commitdiff_plain;h=94967ee29096ece9b64b70f8a9c012d7f6a42008;p=today do a better job propagating errors between components --- diff --git a/web/internal/compile/compile.go b/web/internal/compile/compile.go index c26afc7..b6f1a86 100644 --- a/web/internal/compile/compile.go +++ b/web/internal/compile/compile.go @@ -17,6 +17,7 @@ type Source interface { Name() string Source() include.Opener Includes() []Source + Error() error } type TemplateSource interface { diff --git a/web/page/page.go b/web/page/page.go index 72e9e8a..da7607a 100644 --- a/web/page/page.go +++ b/web/page/page.go @@ -3,6 +3,7 @@ package page import ( "context" + "errors" "html/template" "path/filepath" "strings" @@ -54,6 +55,9 @@ func Funcs(funcs template.FuncMap) Config { func Includes(includes ...compile.Source) Config { return func(p *Page) { + for _, src := range includes { + p.err = errors.Join(p.err, src.Error()) + } p.includes = includes } } diff --git a/web/part/part.go b/web/part/part.go index ef4f253..ac07128 100644 --- a/web/part/part.go +++ b/web/part/part.go @@ -3,6 +3,7 @@ package part import ( "context" + "errors" "text/template" "git.earlybird.gay/today/include" @@ -46,6 +47,9 @@ func Funcs(funcs template.FuncMap) Config { func Includes(includes ...compile.Source) Config { return func(p *Part) { + for _, src := range includes { + p.err = errors.Join(p.err, src.Error()) + } p.includes = includes } }