ref: 305ce1c9ec746d3b8f6c9306b7014bfd621478a5
parent: 3e9db2ad951dbb1000cd0f8f25e4a95445046679
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Mon Mar 2 07:39:26 EST 2020
resources: Add full filename to image when processing fails Fixes #7000
--- a/resources/image.go
+++ b/resources/image.go
@@ -36,6 +36,7 @@
"github.com/gohugoio/hugo/resources/resource"
+ "github.com/pkg/errors"
_errors "github.com/pkg/errors"
"github.com/gohugoio/hugo/helpers"
@@ -234,7 +235,7 @@
var imageProcSem = make(chan bool, imageProcWorkers)
func (i *imageResource) doWithImageConfig(conf images.ImageConfig, f func(src image.Image) (image.Image, error)) (resource.Image, error) {
- return i.getSpec().imageCache.getOrCreate(i, conf, func() (*imageResource, image.Image, error) {
+ img, err := i.getSpec().imageCache.getOrCreate(i, conf, func() (*imageResource, image.Image, error) {
imageProcSem <- true
defer func() {
<-imageProcSem
@@ -291,6 +292,13 @@
return ci, converted, nil
})
+
+ if err != nil {
+ if i.root != nil && i.root.getFileInfo() != nil {
+ return nil, errors.Wrapf(err, "image %q", i.root.getFileInfo().Meta().Filename())
+ }
+ }
+ return img, nil
}
func (i *imageResource) decodeImageConfig(action, spec string) (images.ImageConfig, error) {