0

I have a strange problem with deserialization from external service. I have some lib where I call method and pass params. This method always returns zio.IO[Error, Value]. Inside this lib some magic happens, it connects with other service, get response and return it to me. I create a simple for comprehension example, where I call this method:

for {
  response <- library.someMethod(firstParam, secondParam).map(value => value.code).mapError(error => showError(error))
} yield response

Error and Value here zio.IO[Error, Value] are some custom objects. When I ran this for comprehension code, I got an error, connected with serialization:

The Either on which value was invoked was not defined as a Right; it was Left(sttp.client3.DeserializationException: expected json value got 'Intern...' (line 1, column 1)).
org.scalatest.exceptions.TestFailedException: The Either on which value was invoked was not defined as a Right; it was Left(sttp.client3.DeserializationException: expected json value got 'Intern...' (line 1, column 1)).
    at org.scalatest.EitherValues$Valuable.value(EitherValues.scala:211)

I'm not sure if I need additional decoders or I should change something in for comprehension code to deserialize this value and error? Is it possible to deserialize response and take value correctly?

Developus
  • 1,400
  • 2
  • 14
  • 50
  • 2
    You didn't show us `someMethod`, how does it parse? What's the input data? Look's like you have a plain text but not JSON. – Gaël J Jan 04 '23 at 20:35
  • To be more specific, instead of some json doc like `{}`, `123`, `[1,2,3]`, or `"foo"` you have `Intern...` which isn't a valid start of a json doc. – Sergey Romanovsky Jan 13 '23 at 01:01

0 Answers0