JavaScript Functions > Alphabetical Listing of Utility Functions (lr) > lr.errorMessage

lr.errorMessage

Sends an error message with location details to the output windows, log files, and other test report summaries.

ExampleMessage Functions

Syntax

lr.errorMessage( message );

Arguments

ArgumentComments
messageThe error message to send.

The lr.errorMessage function sends an error message to product output windows log files, and other test report summaries. For details regarding the output for each product, see the products' user guides.

To send a special notification that is not specifically an error message, use lr.outputMessage.

If Run-time settings > General > Miscellaneous > fail open transactions on lr.errorMessage is selected, calling lr.errorMessage will fail the transaction in addition to sending the message. If you want to save the elapsed time in spite of the transaction failure, capture the time with lr.getTransactionDuration before calling lr.errorMessage, then create a transaction to report the time with lr.setTransaction.

It is not recommended that you send a message to the Output window in the middle of a transaction, as it will lengthen the execution time. Instead, use lr.logMessage to send the message only to the Vuser log file. This conserves the resources required for sending messages to the output window.

VuGen displays the message text of the lr.errorMessage function in the Execution log in red, using Error code 17999. Note that this function sends a message to the output even when logging is disabled in the run-time settings.

In the Vuser Execution log, this function lists the location and line number from where the message was issued. To issue a message without those details, use lr.message.

lr.setDebugMessage calls can affect the output from lr.errorMessage.

Output of lr.errorMessage("output message"); - action(4):output message                

Output of lr.message("message"); - message                                                                    

Return Values

On success, returns the length of the message that was sent. On Failure, returns a negative number.

Parameterization

You cannot use standard parameterization for any arguments in this function.

Concept Link IconSee Also

Example

function Action(){
   var status = web.url({name : 'Login',
                url:'https://secure.computing.com//login.asp?user={username}&session={ssid}',
                recContentType:'text/html'});
   if (status == lr.FAIL) {
        lr.errorMessage("Error: Unable to login to secure computing");
        return -1;
   }

return 0;
}