title: Debugging with Gatling - println if status is 500
body: <p>I am performance testing a Play! application which contains a number of GET/POST API's. I want to do some debugging as one single test is mysteriously failing out of hundreds (and it only fails when the whole lot is run). How do I conditionally add println's if the status returned is 500?</p>
  
  <p>I have tried the following, but since <code>session.status</code> isn't an Int it isn't working (ie it always returns false). Also, I don't think that checking <code>session.status</code> is even the right thing to do as when I just print out <code>session.status</code> for every call, it just spits a bunch of lines of <code>OK</code> (not even <code>SEE_OTHER</code> or something similar like I would expect it to be for the successful runs), but I'm not sure what the alternative is.</p>
  
  <pre><code>val postData: ChainBuilder = exec(http(s"[POST] Data sent to API")
    .post(s"$baseUrl/post-data")
    .formParam("id", s"$${id}")
    .check(status.is(303))
    .disableFollowRedirect)
    .exec {
      session =&gt;
        if (session.status == 500) {
          println(session.attributes("id")) // whatever
        }
        session
    }
  </code></pre>
  
  <p>I'm not sure how to do this <code>if</code> check, or where to put it. How do I conditionally check some data within my tests, based on the <code>status</code> of the result?</p>