How can i stop a udf being called if the query is not successful?

Hi,

I have a simple tick script that calls a udf:

var data = batch
    |query(''' 
            DO some query
           
    ''')
        
	.groupBy('host_name')
        .period(1d)
        .every(5m)        
data
    @outlier()
        .field('value')
        .scale(2.0)
    |influxDBOut()
        .create()
        .database(outputDB)
	.retentionPolicy(outputRP)
        .measurement(outputMeasurement)

When influxdb is down, the outlier udf raises an internal error and stops agent. Instead of this, i am looking for a way to not call outlier udf unless the data is valid. Can anyone give me a direction how to achieve it?

Thanks a lot