How can I customize the error message in the HTML report?

Hello, I’m currently using the Java flavor of Gatling 3.11.5.

One of my simulations performs HTTP requests. These requests may fail (400, 403, 500). In these cases the JSON response is something like:

{ ..., "details": "Some detailled error message" }

I’d like to extract and display that error message in the HTML report instead of the default generated “status.find.is(200), but actually found 500”, see snapshot:

This way the HTML report will display and count the various error message types and help me troubleshoot much faster.

Can this be done ?

If your message is the same through failed request, then yes you can.
Just define your success check, for example you have 2 message as:

{
     "message": "Call Success"
}
{
     "message": "Call Fail"
}

If you want to log on the report, then define:

.check(jmesPath("message").is("Call Success"))

Hope this help :slight_smile:
Else if the message is vary… This may help but the log on HTML would be alot…

Edit:
Sample of a fail response on HTML:

jmesPath(message).find.is(Call Success), but actually found "Call Failed"
1 Like

Nice idea, thank you for your help.

Since the JSON attribute is only present for error responses, I used instead:

jsonPath("$.details").withDefault("").is("")

If you have a better solution, I’m all ears.

Now I’m facing a secondary issue. The error response comes with a 500 status. As a consequence Gatling considers that the request failed and displays this in the HTML report instead of my “custom” message:

status.find.is(200), but actually found 500

I tried to ignore such 500 status but nothing worked. I tried multiple solutions:

status().in(200, 500)
status().gt(0)
status().not(0)
status.saveAs("status")

Am I missing something ? How can I ignore HTTP status such as 500, 400, etc ?

I have not been facing this use case before, sadly. :smiling_face_with_tear:
@slandelle kindly tag, I think this case is interesting, do you have any advice ?

If you have a better solution, I’m all ears.

jsonPath("$.details").notExists

Now I’m facing a secondary issue.

New dedicated post then please. One post per concern.

1 Like

Thank you @slandelle for the improvement.

I opened a dedicated issue about the 500 HTTP status I need to ignore: How can I ignore 500 response status of HTTP requests

1 Like

I have additional improvement for you :slight_smile:
Use jmesPath (as @trinp use) instead of jsonPath.
Take my word for it, it’s worth it.
You’ll thank me later :wink: