From 94967ee29096ece9b64b70f8a9c012d7f6a42008 Mon Sep 17 00:00:00 2001 From: early Date: Wed, 6 Nov 2024 19:31:33 -0700 Subject: [PATCH] do a better job propagating errors between components --- web/internal/compile/compile.go | 1 + web/page/page.go | 4 ++++ web/part/part.go | 4 ++++ 3 files changed, 9 insertions(+) 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 } } -- 2.39.5