ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Error Models
    zio/zio2 2022. 11. 20. 23:12

    Errors = failures present in the ZIO type signature ("checked" errors)

    Defects = failures that are unrecoverable, unforeseen, NOT present in the ZIO type signature

     

    ZIO[R,E,A] can finish with Exit[E,A]

        - Success[A] containing a value

        - Cause[E]

             - Fail[E] containing the error

             - Die(t: Throwable) which was unforeseen

     

      val failedInt: ZIO[Any, String, Int] = ZIO.fail("I failed!")
      val failureCauseExposed: ZIO[Any, Cause[String], Int] = failedInt.sandbox
      val failureCauseHidden: ZIO[Any, String, Int] = failureCauseExposed.unsandbox
      
      val foldWithCause = failedInt.foldCause(
        cause => s"this failed with ${cause.defects}",
        value => s"this succeed with $value"
      )

    'zio > zio2' 카테고리의 다른 글

    Ref vs Ref.Synchronized  (0) 2022.12.09
    Fiber  (0) 2022.11.23
    Option 처리하기  (0) 2022.11.20
    ZLayer 를 이용한 dependency injection  (0) 2022.07.27
    java callback 을 ZIO 로 바꾸기  (0) 2022.07.17

    댓글

Designed by Tistory.