Share this page

# lr_error_message

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

    int lr_error_message( char *format, exp1, exp2,...expn. );

Alphabetical Listing - C Language Utility Functions

## Arguments

Name | Comments
--- | ---
format C Language | A formatted string to send to the Output window. You may specify a literal string in quotation marks or use the standard Message Formatting that is available for printf.
exp1, exp2,.. expn C Language | The expressions or variables to be formatted.
message Java | A string containing the error message to send to the Output window. See Java String Arguments.

The lr_error_message function sends an error message to the application's output window, log files, and other test report summaries.

The message size is limited to 5 KB.

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

If Runtime settings > General > Miscellaneous > Fail open transactions on lr_error_message is selected, calling lr_error_message 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_get_transaction_duration before calling lr_error_message, then create a transaction to report the time with lr_set_transaction.

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_log_message 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_error_message 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 runtime 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_set_debug_message calls can affect the output from lr_error_message.

Output of lr_error_message("output message"); - Action(4):output message

Output of lr_message("message"); - message

## Return Values

If this function succeeds, it returns the length of the message that was sent. If the function fails, it returns a negative number.

## Parameterization

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

See Also

## Example

In the following example, lr_error_message sends a message to the output window or log file if login fails:

    int status = web_url("Login",
              "URL=https://secure.computing.com//login.asp?user={username}&session={ssid}",
              "RecContentType=text/html", LAST );

    if (status == LR_FAIL) {
        lr_error_message("Error: %s", "Unable to login to secure computing");
         return -1;
    }

In the next example, we defined a parameter called <`iteration`> that reports the iteration number of the test. The lr_error_message function sends a message indicating the current iteration number.

    int status = web_url("Login",
              "URL=https://secure.computing.com//login.asp?user={username}&session={ssid}",
              "RecContentType=text/html", LAST );

    if (status == LR_FAIL) {
         lr_error_message( "Error at iteration #%s", lr_eval_string( "{iteration}" ) );
         return -1;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: