LoadRunner 11: DIY "Continue on Error" error-handling examples?

1,019 views
Skip to first unread message

Carter, Rick

unread,
Jun 27, 2014, 7:39:49 AM6/27/14
to LR-Loa...@googlegroups.com
Hi,

I'm having a rare 500 error occur in a script. I'm properly checking all my values and pages and known errors along the way, but it still persists. I suspect an error in the underlying test data which is large.

I see I could do something with "Continue on Error" or lr_on_error_continue, and I see it mentioned that that's for users who want to roll their own error checking at that point.

However, I'm not finding any good examples.

Is there anyway I could do an lr_on_error_continue, somehow know that an error has occurred, know what error # it is, and then write my own lr_error_message with the parameters and other info that I choose? Something along the lines of…

lr_on_error_continue;

web_url("…");

if ( somethingorother that lets me know I had an error )
lr_error_message("HTML error {errorcodesomehowobtained} was triggered. User is {UserID}, value #1 is {Value1}, value #2 is {Value2}";
return 1;

...
lr_on_error_no_options


--
Rick Carter
Application Systems Administrator Senior
Information and Technology Services
University of Michigan
rkca...@umich.edu
734-647-5941

James Pulley

unread,
Jun 27, 2014, 10:26:39 AM6/27/14
to LR-Loa...@googlegroups.com
Pcode

Turn on continue on error

Define success with a web_reg_find or web_reg_save_param

Make request

Check for failure to meet success criteria
{
   Branch code for cleanup and return to some intial state to either retry or end the iteration
}

turn off continue on error


Using history as a guide, it is not likely the actual request returning a 500 which is the cause of the issue, but a request one to two requests previous which is returning an unexpected result.   As you then move forward either the application or data is not in the proper state for the next request, i.e. Asking for a balance on a listed account, but one which is closed.   The expected state for the account would be active but this was not checked on a previous request, resulting in a grabbing of a closed account where a balance inquiry is made.

Explicitly checking for expected results and branching with your own code is a minimum requirement for turning on continue on error.   You can force some automatic errors with unsatisfied web_reg...() functions which can cause a script to halt it's iteration but it's an inelegant way, like using an axe to perform surgery.

James Pulley

Carter, Rick

unread,
Jun 27, 2014, 8:55:31 PM6/27/14
to LR-Loa...@googlegroups.com
Thanks, James,

I've been on the lists long enough to know your "where 500 errors usually come from in LoadRunner scripts" mantra, which has helped me make sure I'm checking EVERYTHING (so genuine thanks for hammering on that)… this seems to be a legitimate 1% case of either a rare functional or underlying-data error.

I just realized I can collapse my question to, "If LoadRunner sees a 5xx error, and I continue on error, is there any way to capture *which* 5xx it saw other than web_reg_find/web_reg_save_param the resulting screen? Is the status captured somewhere I can access, so I can use it to custom-create my own error message?" I *think* from extensive research that the answer would be "no," but I've never found an explicit "no."

- Rick

--
Rick Carter
Application Systems Administrator Senior
Information and Technology Services
University of Michigan
rkca...@umich.edu
734-647-5941

--
You received this message because you are subscribed to the Google Groups "LoadRunner" group.
To unsubscribe from this group and stop receiving emails from it, send an email to LR-LoadRunne...@googlegroups.com.
To post to this group, send email to LR-Loa...@googlegroups.com.
Visit this group at http://groups.google.com/group/LR-LoadRunner.
For more options, visit https://groups.google.com/d/optout.

Arun

unread,
Jun 30, 2014, 9:35:16 AM6/30/14
to LR-Loa...@googlegroups.com

Hi Rick

Below code snippet may help you to log and review the test data used in web call to investigate further-

Define int i ; ( somewhere may be in globals.h)

//Whichever web call to the server you think may result in 5xx error or any server side error, for that web call check the return code. web_url, web_submit_data //returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

lr_continue_on_error (0);

i= web_url(" ....someurl....");  //in case if you encounter an error the web call return value as 1 ( tested with 404 error)

lr_continue_on_error(1);

if (i){

 lr_error_message("HTML error {errorcodesomehowobtained} was triggered. User is {UserID}, value #1 is {Value1}, value #2 is {Value2}";

i=0;

return 1;

}

//Also if you are particularly interested to know the HTTP status code you can take use web_get_int_property(HTTP_INFO_RETURN_CODE) function;

//E.g.

int i, HttpRetCode;

i=web_url("my_home",

"URL=http://my_home",

"TargetFrame=_TOP",

LAST );

HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE)

If(i){

lr_output_message(“HTML error %d  UserID1 %s , UserID2 %s", HttpRetCode,{Value1},{Value1});

//lr_error_message("HTML error {errorcodesomehowobtained} was triggered. User is {UserID}, value #1 is {Value1}, value #2 is {Value2}";

i=0;

//Error handler specific to the return code

if (HttpRetCode == 200)

lr_log_message("The script successfully accessed the My_home home page");

else

lr_log_message("The script failed to access the My_home home page ");

}

return 1;

}

Regards

James Pulley

unread,
Jun 30, 2014, 9:48:36 PM6/30/14
to LR-Loa...@googlegroups.com

Thunbs up on the status check…

 

“….HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE)….”

Carter, Rick

unread,
Jul 3, 2014, 11:12:23 AM7/3/14
to LR-Loa...@googlegroups.com
Ah, THERE it is!

Thanks a lot! This is what I've been looking for and missed.

- Rick

--
Rick Carter
Application Systems Administrator Senior
Information and Technology Services
University of Michigan
rkca...@umich.edu
734-647-5941

Reply all
Reply to author
Forward
0 new messages