Skip to content

Commit ef83860

Browse files
committed
internal: phase out DecorateError in favor of errors.Wrap
The former seems to have been a thing in the old evaluator code deleted in 2020, but a single call remained in the subsume package. All that a decorated error did was augment an errors.Error value with a Go error so that errors.Is would work with either. errors.Wrap gives us the same property, and is more consistent with the rest of the codebase nowadays. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I5a3acf0381c83e0e36c18708cfb586ceccc7e2f2 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200973 Reviewed-by: Roger Peppe <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 14e8875 commit ef83860

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

internal/core/subsume/subsume.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (s *subsumer) getError() (err errors.Error) {
138138
}
139139
err = s.errs
140140
if s.inexact {
141-
err = internal.DecorateError(internal.ErrInexact, err)
141+
err = errors.Wrap(err, internal.ErrInexact)
142142
}
143143
return err
144144
}

internal/internal.go

-16
Original file line numberDiff line numberDiff line change
@@ -430,19 +430,3 @@ func GenPath(root string) string {
430430
}
431431

432432
var ErrInexact = errors.New("inexact subsumption")
433-
434-
func DecorateError(info error, err errors.Error) errors.Error {
435-
return &decorated{cueError: err, info: info}
436-
}
437-
438-
type cueError = errors.Error
439-
440-
type decorated struct {
441-
cueError
442-
443-
info error
444-
}
445-
446-
func (e *decorated) Is(err error) bool {
447-
return errors.Is(e.info, err) || errors.Is(e.cueError, err)
448-
}

0 commit comments

Comments
 (0)