iter-iter.go: check ctx against nil on creation
This commit is contained in:
+10
-2
@@ -12,6 +12,8 @@ import (
|
||||
"git.portale-stac.it/go-pkg/expr/scan"
|
||||
)
|
||||
|
||||
const iterIterType = "IterIter"
|
||||
|
||||
type IterIter struct {
|
||||
it kern.Iterator
|
||||
count int64
|
||||
@@ -22,7 +24,13 @@ type IterIter struct {
|
||||
}
|
||||
|
||||
func NewIterIter(it kern.Iterator, ctx kern.ExprContext, exprs []*scan.Term) (iter kern.Iterator, err error) {
|
||||
iter = &IterIter{it: it, count: 0, index: -1, ctx: ctx, exprList: exprs, current: nil}
|
||||
if ctx == nil {
|
||||
err = fmt.Errorf("context is required for %s", iterIterType)
|
||||
} else if it == nil {
|
||||
err = fmt.Errorf("source iterator is required for %s", iterIterType)
|
||||
} else {
|
||||
iter = &IterIter{it: it, count: 0, index: -1, ctx: ctx, exprList: exprs, current: nil}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -31,7 +39,7 @@ func (it *IterIter) String() string {
|
||||
}
|
||||
|
||||
func (it *IterIter) TypeName() string {
|
||||
return "IterIter"
|
||||
return iterIterType
|
||||
}
|
||||
|
||||
func (it *IterIter) HasOperation(name string) bool {
|
||||
|
||||
Reference in New Issue
Block a user