Avoid duplicating nested error causes
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user