generate new template cache if pulling from it fails, instead of bailing out

extreme edge case? probably
This commit is contained in:
Lilian Jónsdóttir 2024-01-23 14:27:50 -08:00
parent 9a42079ae3
commit ffe303f1c6

View file

@ -93,7 +93,13 @@ func RenderTemplate(w http.ResponseWriter, filename string, data *models.Templat
// Get templates from cache // Get templates from cache
template, ok := app.TemplateCache.Cache[filename] template, ok := app.TemplateCache.Cache[filename]
if !ok { 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 // Execute templates in a new buffer