Adjust error handling in ToMath vs try (note)

Closes #13239
This commit is contained in:
Bjørn Erik Pedersen
2025-01-09 08:17:40 +01:00
parent 892b49110e
commit dde9d9d544
4 changed files with 38 additions and 38 deletions

View File

@@ -347,10 +347,14 @@ func (h *HugoSites) render(l logg.LevelLogger, config *BuildCfg) error {
if err == nil {
return nil
}
if strings.Contains(err.Error(), "can't evaluate field Err in type resource.Resource") {
// In Hugo 0.141.0 we replaced the special error handling for resources.GetRemote
// with the more general try.
return fmt.Errorf("%s: Resource.Err was removed in Hugo v0.141.0 and replaced with a new try keyword, see https://gohugo.io/functions/go-template/try/", err)
// In Hugo 0.141.0 we replaced the special error handling for resources.GetRemote
// with the more general try.
if strings.Contains(err.Error(), "can't evaluate field Err in type") {
if strings.Contains(err.Error(), "resource.Resource") {
return fmt.Errorf("%s: Resource.Err was removed in Hugo v0.141.0 and replaced with a new try keyword, see https://gohugo.io/functions/go-template/try/", err)
} else if strings.Contains(err.Error(), "template.HTML") {
return fmt.Errorf("%s: the return type of transform.ToMath was changed in Hugo v0.141.0 and the error handling replaced with a new try keyword, see https://gohugo.io/functions/go-template/try/", err)
}
}
return err
}