/claim #9874
When a Cause contains both a typed failure (Fail) and a defect (Die) or interruption, foldZIO / catchAll uses Cause.failureOrCause and will recover from the typed error, silently dropping the defect/interruption.
Repro from the issue:
val t: Throwable = new RuntimeException("boom")
val dieCause = Cause.die(t)
val combinedCause = dieCause && Cause.fail("boom")
ZIO.failCause(combinedCause).catchAll(_ => ZIO.debug("handled")) *> ZIO.debug("Success")
Change Cause.failureOrCause (and failureTraceOrCause) to return the non-recoverable part (stripFailures) whenever the Cause contains defects or interruption.
This ensures typed error recovery cannot mask defects/interruption.
Added regression test:
ZIOSpec > catchAll > does not recover from typed errors when the cause contains defects (issue 9874)Ran locally:
sbt -Dsbt.supershell=false "clean" \
"coreTestsJVM/testOnly zio.ZIOSpec -- -t 9874"
thecafetron-ctrl
@thecafetron-ctrl
ZIO
@ZIO