From 676925165971f8eeac8f91bebece825b7530fbcb Mon Sep 17 00:00:00 2001 From: shrutiverma97 Date: Wed, 9 Mar 2022 16:26:03 +0530 Subject: [PATCH] fixed test --- zio-http/src/main/scala/zhttp/http/Http.scala | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/zio-http/src/main/scala/zhttp/http/Http.scala b/zio-http/src/main/scala/zhttp/http/Http.scala index 6fc5554760..a8329e1a5a 100644 --- a/zio-http/src/main/scala/zhttp/http/Http.scala +++ b/zio-http/src/main/scala/zhttp/http/Http.scala @@ -4,6 +4,7 @@ import io.netty.buffer.{ByteBuf, ByteBufUtil} import io.netty.channel.ChannelHandler import io.netty.handler.codec.http.HttpHeaderNames import zhttp.html._ +import zhttp.http.HExit.Effect import zhttp.http.headers.HeaderModifier import zhttp.service.server.ServerTime import zhttp.service.{Handler, HttpRuntime, Server} @@ -599,8 +600,19 @@ sealed trait Http[-R, +E, -A, +B] extends (A => ZIO[R, Option[E], B]) { self => case Combine(self, other) => { self.execute(a) match { - case HExit.Empty => other.execute(a) - case u => u.asInstanceOf[HExit[R, E, B]] + case HExit.Effect(zio) => { + Effect( + zio.foldM( + { + case Some(error) => ZIO.fail(Option(error.asInstanceOf[E])) + case None => other.execute(a).toZIO + }, + b => ZIO.succeed(b.asInstanceOf[B]), + ), + ) + } + case HExit.Empty => other.execute(a) + case u => u.asInstanceOf[HExit[R, E, B]] } } }