<p>Found the way to address this problem</p>
<pre><code>    statusChange &lt;- awaitTxStatusChange . getCardanoTxId $ ledgerTx
case statusChange of
    Committed TxInvalid () -&gt; logError @String &quot;Transaction failed&quot;
    Committed TxValid -&gt; logInfo @String &quot;Transaction successful&quot;
    _ -&gt; logInfo @String &quot;something else&quot;
</code></pre>

CC BY-SA 4.0
2022-05-11T04:30:36.040Z
2022-05-17T02:32:49.367Z
2022-05-17T02:32:49.367Z
Nico
<p>Before the 2022-04-06 PAB Release <code>Contracts</code> used to stop execution after validation script failed the transaction sent by <code>submitTxConstraintsWith</code>, but after this release <code>Contract</code> is not stopping its execution anymore and it's just proceeding to the end.</p>
<p>The suspected change which caused this changed behavior is this one <a href="https://github.com/input-output-hk/plutus-apps/pull/360/files" rel="nofollow noreferrer">https://github.com/input-output-hk/plutus-apps/pull/360/files</a></p>
<p>I need to update our code base to accommodate this recent change in behavior in <code>Contract</code> monad.</p>
<pre><code>ledgerTx &lt;- submitTxConstraintsWith @Void lookups tx
logInfo @String $ &quot;In case if validation fails, this line was not reachable before 2022-04-06 release, but now it is&quot;
</code></pre>
<p>There is some logic follows after <code>submitTxConstraintsWith</code> called, that logic should not be executed in case if validation script fails.</p>
<p>What would be the best way to check if validator script failed the transaction to throw an error and make the Contract return?</p>

<plutus><validation><contracts>
Contract is not stopping execution if validation script fails (happened after 2022-04-06 PAB Release)
# Contract is not stopping execution if validation script fails (happened after 2022-04-06 PAB Release)

(Asked by: username_0 on 2022-05-11)

Before the 2022-04-06 PAB Release Contracts used to stop execution after validation script failed the transaction sent by submitTxConstraintsWith, but after this release Contract is not stopping its execution anymore and it's just proceeding to the end.
The suspected change which caused this changed behavior is this one https://github.com/input-output-hk/plutus-apps/pull/360/files
I need to update our code base to accommodate this recent change in behavior in Contract monad.
ledgerTx <- submitTxConstraintsWith @Void lookups tx
logInfo @String $ "In case if validation fails, this line was not reachable before 2022-04-06 release, but now it is"

There is some logic follows after submitTxConstraintsWith called, that logic should not be executed in case if validation script fails.
What would be the best way to check if validator script failed the transaction to throw an error and make the Contract return?

**Tags:** plutus, validation, contracts

---

## 1 answers

### Answer by username_0 on 2022-05-11. Score: 1

Found the way to address this problem
    statusChange <- awaitTxStatusChange . getCardanoTxId $ ledgerTx
case statusChange of
    Committed TxInvalid () -> logError @String "Transaction failed"
    Committed TxValid -> logInfo @String "Transaction successful"
    _ -> logInfo @String "something else"


---

