Heres a code snippet to show the layout of a ChainBuilder I created
.exec(
http(Name)
.post(url)
.body(PebbleFileBody("pebbleTemplate.peb")).asJson()
.basicAuth(username, password)
.check(status().is(200).saveAs("responseStatus"))
.check(
jmesPath("path")
.ofMap()
.find()
.saveAs("appointment")
)
.check(bodyString().saveAs("responseBody"))
)
.exitBlockOnFail(
exec(session -> {
logger.error("Search Session failed for reason: {}", session.getString("responseStatus"));
logger.error("Search Sessions response: \n {}", session.getString("responseBody"));
return session;
})
)
When something goes wrong I want to capture some additional data in a log file using log4j2.
I put this additional logic in an .exitBlockOnFail
.
For some reason, the code in .exitBlockOnFail
is executing even when my checks are passing; I can find the data I need and the request response is 200.
All other requests after this one pass with an OK status. Their exitBlockOnFail
conditionals trigger as well.
The default logging that Gatling provides has been set to log if an error occurs in the requests. Its empty.
Why is the code inside .exitBlockOnFail
executing? Does Gatling provide a way that I can get additional details on what caused a failure?