From ffe303f1c6f95040fbb725ee064eab5b5f3befa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Tue, 23 Jan 2024 14:27:50 -0800 Subject: [PATCH] generate new template cache if pulling from it fails, instead of bailing out extreme edge case? probably --- internal/render/render.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/render/render.go b/internal/render/render.go index 37b6b28..7f648cd 100644 --- a/internal/render/render.go +++ b/internal/render/render.go @@ -93,7 +93,13 @@ func RenderTemplate(w http.ResponseWriter, filename string, data *models.Templat // Get templates from cache template, ok := app.TemplateCache.Cache[filename] if !ok { - app.Logger.Fatal(fmt.Sprintf("Couldn't get %s from template cache, bailing out!", filename)) + app.Logger.Errorf("Couldn't get %s from template cache, dunno what happened, but we're gonna generate a new one", filename) + c, err := GenerateNewTemplateCache() + if err != nil { + app.Logger.Fatal("Error generating template cache, bailing out!") + } + app.TemplateCache = c + template = app.TemplateCache.Cache[filename] } // Execute templates in a new buffer