mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-13 20:24:00 +02:00
Add proper error message when receiving nil in Resource transformation
Closes #6128
This commit is contained in:
@@ -19,6 +19,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/common/collections"
|
"github.com/gohugoio/hugo/common/collections"
|
||||||
"github.com/gohugoio/hugo/common/herrors"
|
"github.com/gohugoio/hugo/common/herrors"
|
||||||
"github.com/gohugoio/hugo/common/hugio"
|
"github.com/gohugoio/hugo/common/hugio"
|
||||||
@@ -43,6 +45,10 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *Spec) Transform(r resource.Resource, t ResourceTransformation) (resource.Resource, error) {
|
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{
|
return &transformedResource{
|
||||||
Resource: r,
|
Resource: r,
|
||||||
transformation: t,
|
transformation: t,
|
||||||
|
Reference in New Issue
Block a user