Skip to content

Commit

Permalink
internal: phase out DecorateError in favor of errors.Wrap
Browse files Browse the repository at this point in the history
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í <mvdan@mvdan.cc>
Change-Id: I5a3acf0381c83e0e36c18708cfb586ceccc7e2f2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200973
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
  • Loading branch information
mvdan committed Sep 12, 2024
1 parent 14e8875 commit ef83860
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
2 changes: 1 addition & 1 deletion internal/core/subsume/subsume.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *subsumer) getError() (err errors.Error) {
}
err = s.errs
if s.inexact {
err = internal.DecorateError(internal.ErrInexact, err)
err = errors.Wrap(err, internal.ErrInexact)
}
return err
}
16 changes: 0 additions & 16 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,3 @@ func GenPath(root string) string {
}

var ErrInexact = errors.New("inexact subsumption")

func DecorateError(info error, err errors.Error) errors.Error {
return &decorated{cueError: err, info: info}
}

type cueError = errors.Error

type decorated struct {
cueError

info error
}

func (e *decorated) Is(err error) bool {
return errors.Is(e.info, err) || errors.Is(e.cueError, err)
}

0 comments on commit ef83860

Please sign in to comment.