Share this page

# lr_fail_trans_with_error

Sets the default status of open transactions to LR_FAIL and sends an error message.

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

## Arguments

Name | Comments
--- | ---
format | A string describing the format to use to write the optional remaining expressions exp 1, exp 2,.. exp n. You may specify a literal string in quotation marks or use the standard Message Formatting that is available for printf.
exp 1, exp 2,.. exp n | The optional expressions (variables) to be formatted and printed.

The lr_fail_trans_with_error function sets the default exit status to LR_FAIL for all open transactions with LR_AUTO in their lr_end_transaction statement and sends an error message.

The message is sent to the output window or log file.

A transaction's final status is defined in the status parameter of the lr_end_transaction statement. If this status is LR_AUTO, then the value is automatically assigned. By default the value assigned is LR_PASS, which signifies a successful transaction. lr_fail_trans_with_error changes this default value to LR_FAIL.

Use the format and exp parameters in the same way as the standard Message Formatting that is available for printf. If it is a literal string, enclose it with quotation marks.

## 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.

## Example

In the following example, the status of transaction t1 is changed to fail because an error has occurred. The specific error string is returned by my_get_error_string and is formatted by lr_fail_trans_with_error as part of the message.

The exit status of transaction t2, which is not LR_AUTO, is unaffected by the call to lr_fail_trans_with_error and it remains LR_PASS.

Copy code

    if (status != SUCCESS)
        lr_fail_trans_with_error("An error has occurred: %s", my_get_error_string(status));
    lr_end_transaction("t1", LR_AUTO);
    lr_end_transaction("t2", LR_PASS);

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