Add proper error message when receiving nil in Resource transformation - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit e5f960245938d8d8b4e99f312e9907f8d3aebf7a
DIR parent 9f497e7b5f77d0eb45d932a2301e648a3cd2d88f
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Mon, 29 Jul 2019 09:36:48 +0200
Add proper error message when receiving nil in Resource transformation
Closes #6128
Diffstat:
M resources/transform.go | 6 ++++++
1 file changed, 6 insertions(+), 0 deletions(-)
---
DIR diff --git 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,