From: early Date: Wed, 23 Oct 2024 05:01:04 +0000 (-0600) Subject: No more panics! X-Git-Url: https://git.earlybird.gay/?a=commitdiff_plain;h=af763240f03d2f9f91c3bb3cce15d320acfd6223;p=today No more panics! --- diff --git a/page/page.go b/page/page.go index d3ea5e9..95879e7 100644 --- a/page/page.go +++ b/page/page.go @@ -26,6 +26,8 @@ type Page struct { template *template.Template templateFuncs template.FuncMap templateLoad render.Loader + + err error } type Config func(*Page) @@ -89,7 +91,8 @@ func New(name string, source string, optional ...func(*Page)) *Page { } result, err := compile.Compile(p, sourceTransform) if err != nil { - panic(err) + p.err = err + return p } p.raw = result.TemplateRaw p.templateLoad = result.TemplateDataLoader @@ -99,7 +102,8 @@ func New(name string, source string, optional ...func(*Page)) *Page { Funcs(result.TemplateFuncs). Parse(result.TemplateRaw) if err != nil { - panic(err) + p.err = err + return p } return p } @@ -175,3 +179,7 @@ func (p *Page) Includes() []compile.Source { func (p *Page) Raw() string { return p.raw } + +func (p *Page) Error() error { + return p.err +}