cockroachdb / errors

Go error library with error portability over the network
Apache License 2.0
2.04k stars 66 forks source link

errors.IsAny does not support multi-error #135

Closed intercept6 closed 1 month ago

intercept6 commented 7 months ago

It appears that errors.IsAny does not support multi-error. https://github.com/cockroachdb/errors/blob/c1cc1919cf999fb018fcd038852e969e3d5631cc/markers/markers.go#L152-L205

errors.Is supports multi-error. https://github.com/cockroachdb/errors/blob/c1cc1919cf999fb018fcd038852e969e3d5631cc/markers/markers.go#L44-L92

Perhaps the following equivalent code can be added to IsAny.

// Recursively try multi-error causes, if applicable. 
        for _, me := range errbase.UnwrapMulti(c) { 
            if Is(me, reference) { 
                return true 
            } 
        } 
dhartunian commented 1 month ago

This fix was recently merged: https://github.com/cockroachdb/errors/pull/140 and the latest release contains the fix.