Skip to content

Commit f7b7aaf

Browse files
committed
internal/core/runtime: do not hide positions in interpreter errors
Currently the error wrapping logic in `extern.go` will hide any positions in the error returned by the interpreter, which ends up hiding useful position information returned by the embed implementation. Fix that by using `errors.Wrap` instead of `errors.New`. Fixes #3320. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I9e50e90456528164b64e74af646a66faf0c90fdf Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198350 Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent bfcfff3 commit f7b7aaf

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cmd/cue/cmd/testdata/script/embed_file_err.txtar

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Test what happens when there is an error an embedded file.
2-
# TODO the error should mention the name of the file where the error is.
2+
# The error should mention the name of the file where the error is.
33

44
env CUE_EXPERIMENT=embed
55
! exec cue vet
@@ -12,6 +12,7 @@ cmp stderr want-stderr
1212
-- want-stderr --
1313
@embed: invalid string:
1414
./x.cue:5:6
15+
schema.json:10:7
1516
-- cue.mod/module.cue --
1617
module: "test.example"
1718
language: version: "v0.9.2"

internal/core/runtime/extern.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func (d *externDecorator) processADTNode(n adt.Node, scope *adt.Vertex) bool {
332332

333333
b, err := c.Compile(name, scope, &attr)
334334
if err != nil {
335-
err = errors.Newf(info.attr.Pos(), "@%s: %v", info.extern, err)
335+
err = errors.Wrap(errors.Newf(info.attr.Pos(), "@%s", info.extern), err)
336336
d.errs = errors.Append(d.errs, err)
337337
return true
338338
}

0 commit comments

Comments
 (0)