Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-07-29 10:36:48 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-07-29 10:59:39 +0300
commite5f960245938d8d8b4e99f312e9907f8d3aebf7a (patch)
tree353622b8a64e314d8dbdd9d53b6954f64ac8b902 /resources
parent9f497e7b5f77d0eb45d932a2301e648a3cd2d88f (diff)
Add proper error message when receiving nil in Resource transformation
Closes #6128
Diffstat (limited to 'resources')
-rw-r--r--resources/transform.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/resources/transform.go b/resources/transform.go
index 35ae25ec4..6a188e789 100644
--- a/resources/transform.go
+++ b/resources/transform.go
@@ -19,6 +19,8 @@ import (
"strconv"
"strings"
+ "github.com/pkg/errors"
+
"github.com/gohugoio/hugo/common/collections"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/hugio"
@@ -43,6 +45,10 @@ var (
)
func (s *Spec) Transform(r resource.Resource, t ResourceTransformation) (resource.Resource, error) {
+ if r == nil {
+ return nil, errors.New("got nil Resource in transformation. Make sure you check with 'with' or 'if' when you get a resource, e.g. with resources.Get.")
+ }
+
return &transformedResource{
Resource: r,
transformation: t,