This fix addresses an issue where catchAll would silently ignore defects when a Cause contained both failures and defects.
The problem occurred because when a Cause included both a failure and a defect (such as Fail and Die), the failure handling logic assumed there were no defects present, which led to defects being ignored.
I modified catchAll so that it explicitly checks for defects before attempting to handle errors. I also added helper methods to Cause to make it easier to detect defects and determine whether an error is recoverable. Defects are now always given precedence over failures, in line with ZIO’s design principles, and interruptions are preserved to ensure that functionality like foreachPar continues to work correctly.
I updated the implementation of ZIO.catchAll, introduced the helper methods Cause.containsDefects and Cause.isRecoverable, and wrote comprehensive tests to cover edge cases. I also updated related error handling methods to keep everything consistent and added documentation to reflect these changes.
Closes #9874 /claim #9874
Shwetas Dhake
@shwetd19
ZIO
@ZIO