Skip to content
Permalink
Browse files

Add proper error message when receiving nil in Resource transformation

Closes #6128
  • Loading branch information...
bep committed Jul 29, 2019
1 parent 9f497e7 commit e5f960245938d8d8b4e99f312e9907f8d3aebf7a
Showing with 6 additions and 0 deletions.
  1. +6 −0 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,

0 comments on commit e5f9602

Please sign in to comment.
You can’t perform that action at this time.