]> git.earlybird.gay Git - today/commitdiff
do a better job propagating errors between components
authorearly <me@earlybird.gay>
Thu, 7 Nov 2024 02:31:33 +0000 (19:31 -0700)
committerearly <me@earlybird.gay>
Thu, 7 Nov 2024 02:31:33 +0000 (19:31 -0700)
web/internal/compile/compile.go
web/page/page.go
web/part/part.go

index c26afc72c4eee006cc637727b952a5d7f95a2099..b6f1a864451fccd4c30fbbf1685d45fe496b95b3 100644 (file)
@@ -17,6 +17,7 @@ type Source interface {
        Name() string
        Source() include.Opener
        Includes() []Source
+       Error() error
 }
 
 type TemplateSource interface {
index 72e9e8adaaa3113c73845b547f30881cbebcb03c..da7607ad56cf46e0cabac505e4c75e7d082665ea 100644 (file)
@@ -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
        }
 }
index ef4f253c39b5190e4bfa3bec2632e0103a293912..ac071283454b4c434063b8a45cd6f8a24bba7a77 100644 (file)
@@ -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
        }
 }