# Failing a Script

Use the *fail()* method to halt the script and display an error message. If the script is used on a step transition, this method also prevents the step from proceeding to the next screen.

**Example expression:**

{% code overflow="wrap" %}

```markup
-exp 'if (!step.hasValue( ::Batch ID:: )) { fail(::Batch ID step UDF is required::) }'
```

{% endcode %}

Note that this example also uses the *hasValue* function (see [Handling Non-Existent UDFs/Custom Fields](https://help.connected.illumina.com/clarity-lims/integration-toolkits/lltk/lltk-specifying-custom-fields#handling-non-existent-udfscustom-fields)).
