Skip to main content

JMeter - Error Handling

JMeter - Error Handling

I have been working on POC to check how far JMeter is compatible for migrating from LoadRunner. During the process there are few thing I have encountered which are not readily available in JMeter components or plugins available but achievable.
  • Error Handling - In case of any error during the flow, logout need to be called before next iteration.
I tried searching Online for anything related but I couldn't find any, below is how I have handled the above mentioned.

Error Handling


I tried to implement error handling in various different ways after multiple tries, I identified that "If" controller would work to implement "Try Catch". I initially tried with Parent Controller as "IF" and "Transaction Controller" nested under it, but the problem is that in case if there is an error in "Transaction Controller" is not being reported to any Listener. Eventually after investigation I found that the parent controller takes presidency and I switched the Controllers which worked.


Above snapshot show the hierarchy of the nested components to achieve Error Handling.

1. Thread Group: Set Continue on error as we would be handling error logic

2. Transaction Controller: This hold the requests from business transaction.


3. IF Controller (Try): This verifies if there is failure in requests placed under it, in case of any failure, request flow is stopped and continued to next IF Controller on 4.

4. IF Controller - Else(Catch): When ever there is an issue under 3 if goes through 4. All the error Logic should be placed under it.

5. Error Handler Module Controller: Route to the Error handling 6.

6. Error Handler - Fragment: This holds error logic.

7. Transaction Controller: Logout transaction.

8. JSR233 Sampler - error handler logic: Log error message and start next Iteration as logout is already completed on error in step 7.
If you run with above setup the on error Logout will be executed before next iteration. I have simulated request failure using dummy sampler as below.

Sample JMeter Script for error Handling GitHub.
I see that the actual script that I used earlier seems to have some problem, created a basic script this time compressed