Skip to content

Commit 791f290

Browse files
lunnyKN4CK3Rdelvh
authored
Display error log when a modified template has an error so that it could recovery when the error fixed (#22261) (#22321)
backport #22261 A drawback is the previous generated template has been cached, so you cannot get error in the UI but only from log Co-authored-by: KN4CK3R <[email protected]> Co-authored-by: delvh <[email protected]>
1 parent 58e642c commit 791f290

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

modules/templates/htmlrenderer.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,15 @@ func HTMLRenderer(ctx context.Context) (context.Context, *render.Render) {
7676
compilingTemplates = false
7777
if !setting.IsProd {
7878
watcher.CreateWatcher(ctx, "HTML Templates", &watcher.CreateWatcherOpts{
79-
PathsCallback: walkTemplateFiles,
80-
BetweenCallback: renderer.CompileTemplates,
79+
PathsCallback: walkTemplateFiles,
80+
BetweenCallback: func() {
81+
defer func() {
82+
if err := recover(); err != nil {
83+
log.Error("PANIC: %v\n%s", err, log.Stack(2))
84+
}
85+
}()
86+
renderer.CompileTemplates()
87+
},
8188
})
8289
}
8390
return context.WithValue(ctx, rendererKey, renderer), renderer

0 commit comments

Comments
 (0)