Export ErrNoColumns, name the cure for a shell-split template and an unquoted record, and name the flag a missing data path came from
This commit is contained in:
@@ -140,7 +140,7 @@ func (f *Generator) FakeRecord(path string) (*Record, error) {
|
||||
return nil, fmt.Errorf("fejkdata: %s descends into %q, a field; only a category-level template is a record", path, tail[0])
|
||||
}
|
||||
shape := f.recordShapeOf(n)
|
||||
if errors.Is(shape.err, errNoColumns) {
|
||||
if errors.Is(shape.err, ErrNoColumns) {
|
||||
ns := names(segments)
|
||||
return nil, fmt.Errorf(`fejkdata: %s %w; render it as a column of one: {"format":"","%s":"{/%s}"}`, path, shape.err, ns[len(ns)-1], path)
|
||||
}
|
||||
@@ -231,9 +231,9 @@ func (f *Generator) FakeRecordTemplate(input string) (*Record, error) {
|
||||
return t.Fake(), nil
|
||||
}
|
||||
|
||||
// errNoColumns is the one record fence a path can answer, so its entry point names
|
||||
// ErrNoColumns is the one record fence a path can answer, so its entry point names
|
||||
// the record to write instead.
|
||||
var errNoColumns = errors.New("has no fields, so no columns")
|
||||
var ErrNoColumns = errors.New("has no fields, so no columns")
|
||||
|
||||
// recordOf is the fence both record entry points pass. The columns come back with
|
||||
// the template, fixed for every draw the caller goes on to make.
|
||||
@@ -247,7 +247,7 @@ func recordOf(n node) (*template, []Column, error) {
|
||||
}
|
||||
names := recordColumns(t)
|
||||
if len(names) == 0 {
|
||||
return nil, nil, errNoColumns
|
||||
return nil, nil, ErrNoColumns
|
||||
}
|
||||
if !t.record {
|
||||
return nil, nil, fmt.Errorf("carries repeat %d, which composes its format into one string; a record projects columns instead — drop the repeat and render the record again for more rows", t.repeat)
|
||||
|
||||
Reference in New Issue
Block a user