Skip to content

Commit

Permalink
Don't wrap errors in vector put operator (#5536)
Browse files Browse the repository at this point in the history
The sequence put operator passes errors along unmodified while the
vector operator wraps them inside another error.  Make the vector
implementation behave like the sequence implementation.
  • Loading branch information
nwt authored Dec 16, 2024
1 parent 44ac523 commit 2d5ecb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runtime/vam/expr/putter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func (p *Putter) Eval(vec vector.Any) vector.Any {

func (p *Putter) eval(vecs ...vector.Any) vector.Any {
vec := vecs[0]
if vec.Type().Kind() != super.RecordKind {
if k := vec.Type().Kind(); k != super.RecordKind {
if k == super.ErrorKind {
return vec
}
return vector.NewWrappedError(p.zctx, "put: not a record", vec)
}
return p.recordExpr.Eval(vec)
Expand Down
2 changes: 2 additions & 0 deletions runtime/ztests/op/put-non-record.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ vector: true

input: |
0
error("kaboom")
output: |
error({message:"put: not a record",on:0})
error("kaboom")

0 comments on commit 2d5ecb0

Please sign in to comment.