From 9f765c85a0a15ed68643155f9aafe632c83aa842 Mon Sep 17 00:00:00 2001 From: Adam Warski Date: Wed, 9 Oct 2024 16:09:25 +0200 Subject: [PATCH] Revert "Add more detail to exceptions thrown in the client interpreter" (#4094) --- .../client/sttp/SttpClientInterpreter.scala | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/client/sttp-client/src/main/scala/sttp/tapir/client/sttp/SttpClientInterpreter.scala b/client/sttp-client/src/main/scala/sttp/tapir/client/sttp/SttpClientInterpreter.scala index c110b10785..651f208841 100644 --- a/client/sttp-client/src/main/scala/sttp/tapir/client/sttp/SttpClientInterpreter.scala +++ b/client/sttp-client/src/main/scala/sttp/tapir/client/sttp/SttpClientInterpreter.scala @@ -92,16 +92,17 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions { def toRequestThrowErrors[I, E, O, R](e: PublicEndpoint[I, E, O, R], baseUri: Option[Uri])(implicit wsToPipe: WebSocketToPipe[R] ): I => Request[O, R] = - i => { - val request = new EndpointToSttpClient(sttpClientOptions, wsToPipe).toSttpRequest(e, baseUri).apply(()).apply(i) - request + i => + new EndpointToSttpClient(sttpClientOptions, wsToPipe) + .toSttpRequest(e, baseUri) + .apply(()) + .apply(i) .mapResponse(throwDecodeFailures) .mapResponse { - case Left(t: Throwable) => throw new RuntimeException(throwErrorExceptionMsg(e, i, t.asInstanceOf[E], request), t) - case Left(t) => throw new RuntimeException(throwErrorExceptionMsg(e, i, t, request)) + case Left(t: Throwable) => throw new RuntimeException(throwErrorExceptionMsg(e, i, t.asInstanceOf[E]), t) + case Left(t) => throw new RuntimeException(throwErrorExceptionMsg(e, i, t)) case Right(o) => o } - } // secure @@ -191,16 +192,17 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions { wsToPipe: WebSocketToPipe[R] ): A => I => Request[O, R] = a => - i => { - val request = new EndpointToSttpClient(sttpClientOptions, wsToPipe).toSttpRequest(e, baseUri).apply(a).apply(i) - request + i => + new EndpointToSttpClient(sttpClientOptions, wsToPipe) + .toSttpRequest(e, baseUri) + .apply(a) + .apply(i) .mapResponse(throwDecodeFailures) .mapResponse { - case Left(t: Throwable) => throw new RuntimeException(throwErrorExceptionMsg(e, a, i, t.asInstanceOf[E], request), t) - case Left(t) => throw new RuntimeException(throwErrorExceptionMsg(e, a, i, t, request)) + case Left(t: Throwable) => throw new RuntimeException(throwErrorExceptionMsg(e, a, i, t.asInstanceOf[E]), t) + case Left(t) => throw new RuntimeException(throwErrorExceptionMsg(e, a, i, t)) case Right(o) => o } - } // @@ -211,11 +213,11 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions { case f => throw new IllegalArgumentException(s"Cannot decode: $f") } - private def throwErrorExceptionMsg[I, E, O, R](endpoint: PublicEndpoint[I, E, O, R], i: I, e: E, r: Request[_, _]): String = - s"Endpoint ${endpoint.show} returned error: $e, inputs: $i. Request: ${r.showBasic}." + private def throwErrorExceptionMsg[I, E, O, R](endpoint: PublicEndpoint[I, E, O, R], i: I, e: E): String = + s"Endpoint ${endpoint.show} returned error: $e, inputs: $i." - private def throwErrorExceptionMsg[A, I, E, O, R](endpoint: Endpoint[A, I, E, O, R], a: A, i: I, e: E, r: Request[_, _]): String = - s"Endpoint ${endpoint.show} returned error: $e, for security inputs: $a, inputs: $i. Request: ${r.showBasic}." + private def throwErrorExceptionMsg[A, I, E, O, R](endpoint: Endpoint[A, I, E, O, R], a: A, i: I, e: E): String = + s"Endpoint ${endpoint.show} returned error: $e, for security inputs: $a, inputs: $i." } object SttpClientInterpreter {