Share this page

# lr.failTransWithError

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

Transaction Functions

## Syntax

    lr.failTransWithError( errorMessage );

## Arguments

Argument | Comments
--- | ---
errorMessage | The message to output.

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

The message is sent to the output window.

A transaction's final status is defined in the status parameter of the lr.endTransaction 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.failTransWithError changes this default value to LR_FAIL.

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

## Example

    function Action(){
       var status = -1;
       if (status != lr.SUCCESS)
            lr.failTransWithError("An error has occurred");
       lr.endTransaction("t1", lr.AUTO);
       lr.endTransaction("t2",lr.PASS);
       return 0;
    }

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: