Prevent confusing template errors when seq is nil

The common is the `where` func and this:

```
panic: reflect: call of reflect.Value.Type on zero Value [recovered]
	panic: reflect: call of reflect.Value.Type on zero Value
```
This commit is contained in:
Bjørn Erik Pedersen 2016-02-09 19:00:07 +01:00
parent 2b3b90a6df
commit 8fe1070872

View file

@ -814,7 +814,7 @@ func where(seq, key interface{}, args ...interface{}) (r interface{}, err error)
}
return rv.Interface(), nil
default:
return nil, errors.New("can't iterate over " + reflect.ValueOf(seq).Type().String())
return nil, fmt.Errorf("can't iterate over %v", seq)
}
}
@ -858,7 +858,7 @@ func apply(seq interface{}, fname string, args ...interface{}) (interface{}, err
return r, nil
default:
return nil, errors.New("can't apply over " + reflect.ValueOf(seq).Type().String())
return nil, fmt.Errorf("can't apply over %v", seq)
}
}
@ -950,7 +950,7 @@ func delimit(seq, delimiter interface{}, last ...interface{}) (template.HTML, er
}
default:
return "", errors.New("can't iterate over " + reflect.ValueOf(seq).Type().String())
return "", fmt.Errorf("can't iterate over %v", seq)
}
return template.HTML(str), nil