how to fail a session/chain?

Hi guys,
I have the following as part of a simulation. I want to add the code highlighted below, that will allow me to fail the check and the session, if certain conditions would happen (e.g. I need to catch a parsing exception, due to some errors on the response from the server)
What the recommended way of doing it?

string => {
val json = JSONValue.parse(string).asInstanceOf[JSONObject]
var result = new JSONObject()
if ( iDontLike(json) ) Failure(“this json is full of hot air”)
//populate result here with processed values

Thank you,
Radu Munteanu


You’d either have to write your own check (beware, API changed a lot lately), or use latest snapshot, because transform signature was changed to Option[X] => Validation[Option[Y]] (so that’s exactly what you’re trying to do).