Throw exception on 0 documents
Hi All,
Apologies if this one has been asked before.
There is a scenario in the current pipeline being developed where after a filter operation the number of documents returned can be 0. at this point the pipeline completes as there is no further processing to be done.
I am looking for a pattern to capture this scenario so when there are 0 documents after this step in the process to throw an exception rather than fail silently.
has anyone come across this issue before?
Many thanks,
Kareem.
HI @ksalem,
You can build a mechanism that will check for existing documents, by using the Gate snap.
The Gate Snap will move the pipeline flow even if no documents are provided on the input. From there you can simply add a router that will check for documents (Ex.
$input.lenght == 0
) and throw an error by using the Exit snap.Hope this helps,
Bojan