diff --git a/core/src/main/scala/io/github/gaelrenoux/tranzactio/ConnectionSource.scala b/core/src/main/scala/io/github/gaelrenoux/tranzactio/ConnectionSource.scala index d787d2e..f17ed65 100644 --- a/core/src/main/scala/io/github/gaelrenoux/tranzactio/ConnectionSource.scala +++ b/core/src/main/scala/io/github/gaelrenoux/tranzactio/ConnectionSource.scala @@ -33,7 +33,7 @@ object ConnectionSource { .zipRight(task(c).mapError(Right(_))) .tapErrorCause { (queryCause: Cause[Either[DbException, E]]) => (if (commitOnFailure) commitConnection(c) else rollbackConnection(c)) - .mapErrorCause { rollbackCause => rollbackCause.map(Left(_)) && queryCause } + .mapErrorCause { rollbackCause => queryCause ++ rollbackCause.map(Left(_)) } } .zipLeft(commitConnection(c).mapError(Left(_))) } diff --git a/core/src/test/scala/io/github/gaelrenoux/tranzactio/ConnectionSourceTest.scala b/core/src/test/scala/io/github/gaelrenoux/tranzactio/ConnectionSourceTest.scala index 3c09fda..9c4cd8f 100644 --- a/core/src/test/scala/io/github/gaelrenoux/tranzactio/ConnectionSourceTest.scala +++ b/core/src/test/scala/io/github/gaelrenoux/tranzactio/ConnectionSourceTest.scala @@ -71,10 +71,10 @@ object ConnectionSourceTest extends ZIOSpec[TestEnvironment] { val cs = new FailingConnectionSource(errorStrategies)(failOnCommit = true) val zio: ZIO[Any, Either[DbException, String], Int] = cs.runTransaction(_ => ZIO.fail("Not a good query"), commitOnFailure = true) zio.cause.map { - case Cause.Both(Cause.Fail(left, _), Cause.Fail(right, _)) => + case Cause.Then(Cause.Fail(firstError, _), Cause.Fail(secondError, _)) => assertTrue( - left == Left(DbException.Wrapped(FailingConnectionSource.CommitException)), - right == Right("Not a good query") + firstError == Right("Not a good query"), + secondError == Left(DbException.Wrapped(FailingConnectionSource.CommitException)) ) } } @@ -83,10 +83,10 @@ object ConnectionSourceTest extends ZIOSpec[TestEnvironment] { val cs = new FailingConnectionSource(errorStrategies)(failOnRollback = true) val zio: ZIO[Any, Either[DbException, String], Int] = cs.runTransaction(_ => ZIO.fail("Not a good query")) zio.cause.map { - case Cause.Both(Cause.Fail(left, _), Cause.Fail(right, _)) => + case Cause.Then(Cause.Fail(firstError, _), Cause.Fail(secondError, _)) => assertTrue( - left == Left(DbException.Wrapped(FailingConnectionSource.RollbackException)), - right == Right("Not a good query") + firstError == Right("Not a good query"), + secondError == Left(DbException.Wrapped(FailingConnectionSource.RollbackException)) ) } }