From 023d9e3b09f514649f575a44bb6fb3a010ea32b8 Mon Sep 17 00:00:00 2001 From: ghostbuster91 Date: Fri, 16 Aug 2024 22:25:58 +0200 Subject: [PATCH] Try to restore bincompat --- .../src/smithy4s/http/HttpErrorSelector.scala | 28 ++++++++++++------- .../core/src/smithy4s/http/HttpResponse.scala | 3 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/core/src/smithy4s/http/HttpErrorSelector.scala b/modules/core/src/smithy4s/http/HttpErrorSelector.scala index 8d3739eb8b..0042732f5f 100644 --- a/modules/core/src/smithy4s/http/HttpErrorSelector.scala +++ b/modules/core/src/smithy4s/http/HttpErrorSelector.scala @@ -41,6 +41,12 @@ object HttpErrorSelector { def apply[F[_]: Covariant, E]( maybeErrorSchema: Option[ErrorSchema[E]], compiler: CachedSchemaCompiler[F] + ): HttpDiscriminator => Option[F[E]] = + makeWithReason(maybeErrorSchema, compiler).andThen(_.toOption) + + def makeWithReason[F[_]: Covariant, E]( + maybeErrorSchema: Option[ErrorSchema[E]], + compiler: CachedSchemaCompiler[F] ): HttpDiscriminator => Either[String, F[E]] = maybeErrorSchema match { case None => _ => Left("error schema not found") case Some(errorschema) => @@ -61,19 +67,21 @@ object HttpErrorSelector { def asThrowable[F[_]: Covariant, E]( maybeErrorSchema: Option[ErrorSchema[E]], compiler: CachedSchemaCompiler[F] - ): HttpDiscriminator => Option[F[Throwable]] = asThrowableWithError(maybeErrorSchema, compiler).andThen(_.toOption) + ): HttpDiscriminator => Option[F[Throwable]] = + asThrowableWithReason(maybeErrorSchema, compiler).andThen(_.toOption) - def asThrowableWithError[F[_]: Covariant, E]( + def asThrowableWithReason[F[_]: Covariant, E]( maybeErrorSchema: Option[ErrorSchema[E]], compiler: CachedSchemaCompiler[F] - ): HttpDiscriminator => Either[String, F[Throwable]] = maybeErrorSchema match { - case None => _ => Left("error schema not found") - case Some(errorschema) => - new HttpErrorSelector[F, E]( - errorschema.alternatives, - compiler - ).andThen(_.map(Covariant[F].map(_)(errorschema.unliftError))) - } + ): HttpDiscriminator => Either[String, F[Throwable]] = + maybeErrorSchema match { + case None => _ => Left("error schema not found") + case Some(errorschema) => + new HttpErrorSelector[F, E]( + errorschema.alternatives, + compiler + ).andThen(_.map(Covariant[F].map(_)(errorschema.unliftError))) + } } diff --git a/modules/core/src/smithy4s/http/HttpResponse.scala b/modules/core/src/smithy4s/http/HttpResponse.scala index f115eeb783..c267de1f78 100644 --- a/modules/core/src/smithy4s/http/HttpResponse.scala +++ b/modules/core/src/smithy4s/http/HttpResponse.scala @@ -220,7 +220,8 @@ object HttpResponse { ): Decoder[F, Body, Throwable] = discriminating( discriminate, - HttpErrorSelector.asThrowableWithError(maybeErrorSchema, decoderCompiler), + HttpErrorSelector + .asThrowableWithReason(maybeErrorSchema, decoderCompiler), toStrict )