mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-11 18:14:15 +01:00
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>
This commit is contained in:
parent
f0159c3e8a
commit
c59e1537a8
1 changed files with 9 additions and 2 deletions
|
@ -75,8 +75,15 @@ func HTMLRenderer(ctx context.Context) (context.Context, *render.Render) {
|
||||||
compilingTemplates = false
|
compilingTemplates = false
|
||||||
if !setting.IsProd {
|
if !setting.IsProd {
|
||||||
watcher.CreateWatcher(ctx, "HTML Templates", &watcher.CreateWatcherOpts{
|
watcher.CreateWatcher(ctx, "HTML Templates", &watcher.CreateWatcherOpts{
|
||||||
PathsCallback: walkTemplateFiles,
|
PathsCallback: walkTemplateFiles,
|
||||||
BetweenCallback: renderer.CompileTemplates,
|
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
|
return context.WithValue(ctx, rendererKey, renderer), renderer
|
||||||
|
|
Loading…
Reference in a new issue