I'm using Play's WSClient to interact with a third-party service
request = ws.url(baseUrl)
.post(data)
.map{ response =>
response.json.validate[MyResponseClass]
The response may be a MyResponseClass or it may be an ErrorResponse like { "error": [ { "message": "Error message" } ] }
Is there a typical way to parse either the Class or the Error?
Should i do something like this?
response.json.validateOpt[MyResponseClass].getOrElse(response.json.validateOpt[ErrorClass])