Avoid duplicating nested error causes

This commit is contained in:
2026-11-05 16:00:39 +00:00
parent ac1e150168
commit 4aeb58f913
3 changed files with 25 additions and 7 deletions

View File

@@ -30,12 +30,9 @@ func mapPublicError(err error) error {
if errors.Is(operation.Cause, llm.ErrMalformedResponse) {
mapped = errors.Join(ErrMalformedResponse, mapped)
}
var internalCapacity *usecase.CapacityError
var internalProvider *llm.ProviderHTTPError
if errors.As(operation.Cause, &internalCapacity) || errors.As(operation.Cause, &internalProvider) {
return errors.Join(owner, mapped)
}
return errors.Join(owner, mapped, operation.Cause)
// The projection already retains ordinary causes; adding the original
// again would duplicate its entire subtree at each enclosing operation.
return errors.Join(owner, mapped)
}
}
return mapUnownedPublicError(err)