Error if channel is NOT empty

If a channel is empty, the following operator won’t do anything so simply add a map on the end of your channel.

params.input = false
workflow {
    ch_in = params.input ? Channel.fromList([1, 2, 3]) : Channel.empty()
    ch_in.map{ error "Error: Channel is not empty" }
}
1 Like