diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-01-03 15:17:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-03 15:17:36 +0800 |
commit | c59e1537a8bb57af0ca19c0adfe8ab613c567193 (patch) | |
tree | 8d677ac8d7a135109e973894c154f729040bbd75 /modules/templates/htmlrenderer.go | |
parent | f0159c3e8ae3e48848c16ddda3529e34b80665f5 (diff) | |
download | gitea-c59e1537a8bb57af0ca19c0adfe8ab613c567193.tar.gz gitea-c59e1537a8bb57af0ca19c0adfe8ab613c567193.zip |
Display error log when a modified template has an error so that it could recovery when the error fixed (#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 <admin@oldschoolhack.me>
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'modules/templates/htmlrenderer.go')
-rw-r--r-- | modules/templates/htmlrenderer.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/templates/htmlrenderer.go b/modules/templates/htmlrenderer.go index 7ab523822b..5a328043eb 100644 --- a/modules/templates/htmlrenderer.go +++ b/modules/templates/htmlrenderer.go @@ -75,8 +75,15 @@ func HTMLRenderer(ctx context.Context) (context.Context, *render.Render) { compilingTemplates = false if !setting.IsProd { watcher.CreateWatcher(ctx, "HTML Templates", &watcher.CreateWatcherOpts{ - PathsCallback: walkTemplateFiles, - BetweenCallback: renderer.CompileTemplates, + PathsCallback: walkTemplateFiles, + BetweenCallback: func() { + defer func() { + if err := recover(); err != nil { + log.Error("PANIC: %v\n%s", err, log.Stack(2)) + } + }() + renderer.CompileTemplates() + }, }) } return context.WithValue(ctx, rendererKey, renderer), renderer |