Closed grmble closed 5 years ago
The problem is/was doobie AFAIK, before doobie used naked throw
instead of raiseError
in many places, see:
https://github.com/tpolecat/doobie/pull/837
https://github.com/tpolecat/doobie/issues/836
https://github.com/tpolecat/doobie/issues/800
We sandbox all doobie calls in production codebase for that reason. Are you sure you're not affected simply by naked throws? Are you on a recent enough version of doobie, after the PR above was merged?
You are correct, the doobie version was too old. 0.5.x has the problem, it goes away with 0.7.0 or newer.
Sorry for the noise.
I think this issue has popped back up with doobie version 0.10.0. Is there a better workaround than using sandbox to extract the exception and move it into the error channel?
@hollinwilkins You can use .absorb
method on ZIO to convert defect into a typed error
If a unique doobie select fails because the row does not exist, and that Task is turned into an UIO via either, the result is not a Left as I would have expected, but an Exception is thrown.
I don't think the problem is with doobie - when using cats-effect instead of zio the behavior is as expected.
This fails with the following error:
X me.gmeiner.stoic.server.auth.DoobieUniqueTest.Find non-existing user 1827ms zio.FiberFailure: Fiber failed. An unchecked error was produced. doobie.util.invariant$UnexpectedEnd$: ResultSet exhausted; more rows expected. at doobie.util.invariant$UnexpectedEnd$.(invariant.scala)
at doobie.hi.resultset$.$anonfun$getUnique$1(resultset.scala:195)
at doobie.hi.resultset$.$anonfun$getUnique$1$adapted(resultset.scala:192)
at cats.SemigroupalArityFunctions.$anonfun$map2$1(SemigroupalArityFunctions.scala:30)
at cats.Monad.$anonfun$map$1(Monad.scala:16)
at cats.free.Free.$anonfun$step$1(Free.scala:52)
at cats.free.Free.step(Free.scala:53)
at cats.free.Free.$anonfun$foldMap$1(Free.scala:153)
at cats.data.KleisliFlatMap.$anonfun$tailRecM$2(Kleisli.scala:534)
at zio.interop.CatsMonad.$anonfun$tailRecM$1(catsjvm.scala:252)
at zio.ZIOFunctions.$anonfun$suspend$1(ZIO.scala:1444)
at zio.internal.FiberContext.evaluateNow(FiberContext.scala:485)
at zio.Runtime.unsafeRunAsync(Runtime.scala:94)
at zio.Runtime.unsafeRunAsync$(Runtime.scala:80)
at me.gmeiner.stoic.server.auth.DoobieUniqueTest$$anon$1.unsafeRunAsync(DoobieUniqueTest.scala:12)
at zio.Runtime.unsafeRunSync(Runtime.scala:69)
at zio.Runtime.unsafeRunSync$(Runtime.scala:66)
at me.gmeiner.stoic.server.auth.DoobieUniqueTest$$anon$1.unsafeRunSync(DoobieUniqueTest.scala:12)
at zio.Runtime.unsafeRun(Runtime.scala:58)
at zio.Runtime.unsafeRun$(Runtime.scala:57)
at me.gmeiner.stoic.server.auth.DoobieUniqueTest$$anon$1.unsafeRun(DoobieUniqueTest.scala:12)
at me.gmeiner.stoic.server.auth.DoobieUniqueTest$.$anonfun$tests$2(DoobieUniqueTest.scala:17)