diff options
Diffstat (limited to 'internal/pkg/pkg.go')
| -rw-r--r-- | internal/pkg/pkg.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index 38bd550d..378d0166 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -1485,8 +1485,8 @@ func (c *Cache) Cure(a Artifact) ( // CureError wraps a non-nil error returned attempting to cure an [Artifact]. type CureError struct { - Ident unique.Handle[ID] - Err error + A Artifact + Err error } // Unwrap returns the underlying error. @@ -1499,22 +1499,22 @@ func (e *CureError) Error() string { return e.Err.Error() } type DependencyCureError []*CureError // unwrapM recursively expands underlying errors into a caller-supplied map. -func (e *DependencyCureError) unwrapM(me map[unique.Handle[ID]]*CureError) { +func (e *DependencyCureError) unwrapM(me map[Artifact]*CureError) { for _, err := range *e { - if _, ok := me[err.Ident]; ok { + if _, ok := me[err.A]; ok { continue } if _e, ok := err.Err.(*DependencyCureError); ok { _e.unwrapM(me) continue } - me[err.Ident] = err + me[err.A] = err } } // unwrap recursively expands and deduplicates underlying errors. func (e *DependencyCureError) unwrap() DependencyCureError { - me := make(map[unique.Handle[ID]]*CureError) + me := make(map[Artifact]*CureError) e.unwrapM(me) errs := slices.AppendSeq( make(DependencyCureError, 0, len(me)), @@ -1522,8 +1522,9 @@ func (e *DependencyCureError) unwrap() DependencyCureError { ) var identBuf [2]ID + ir := NewIR() slices.SortFunc(errs, func(a, b *CureError) int { - identBuf[0], identBuf[1] = a.Ident.Value(), b.Ident.Value() + identBuf[0], identBuf[1] = ir.Ident(a.A).Value(), ir.Ident(b.A).Value() return slices.Compare(identBuf[0][:], identBuf[1][:]) }) @@ -1548,8 +1549,11 @@ func (e *DependencyCureError) Error() string { } var buf strings.Builder buf.WriteString("errors curing dependencies:") + ir := NewIR() for _, err := range errs { - buf.WriteString("\n\t" + Encode(err.Ident.Value()) + ": " + err.Error()) + buf.WriteString("\n\t" + + reportName(err.A, ir.Ident(err.A)) + ": " + + err.Error()) } return buf.String() } @@ -2082,7 +2086,7 @@ func (pending *pendingArtifactDep) cure(c *Cache) { } pending.errsMu.Lock() - *pending.errs = append(*pending.errs, &CureError{c.Ident(pending.a), err}) + *pending.errs = append(*pending.errs, &CureError{pending.a, err}) pending.errsMu.Unlock() } |
