I am using Scala STTP
I have a call to an api that is constructed as this:
val request = basicRequest
.get(uri"$fullUri")
.headers(headers)
.response(asJson[MyClass])
Is it possible to cast errors returned to a different case class with similar approach (ex: asJson
method)
So basically I would want to add that potential cast in response body result here:
case Success(result) =>
if (result.code != StatusCode.Ok) {
# try to cast here
}
result.body match {
case Left(error) =>
# Try to cast here
case Right(r) => Right(r)
}