transactionFailed()

in src/TransactionLockHelper.ts [173:207]


  transactionFailed(token: TransactionToken, message: string) {
    const pendingTransIndex = findIndex(
      this._pendingTransactions,
      (trans) => trans.token === token
    );
    if (pendingTransIndex !== -1) {
      const pendingTrans = this._pendingTransactions[pendingTransIndex];
      if (pendingTrans.completionDefer) {
        pendingTrans.hadSuccess = false;

        const toResolve = pendingTrans.completionDefer;
        this._pendingTransactions.splice(pendingTransIndex, 1);
        pendingTrans.completionDefer = undefined;
        toResolve.reject(new Error(message));
      } else {
        throw new Error(
          "Failing a transaction that has already been completed. Stores: " +
            token.storeNames.join(",") +
            ", HadSuccess: " +
            pendingTrans.hadSuccess +
            ", Message: " +
            message
        );
      }
    } else {
      throw new Error(
        "Failing a transaction that is no longer tracked. Stores: " +
          token.storeNames.join(",") +
          ", message: " +
          message
      );
    }

    this._cleanTransaction(token);
  }