Intercepting the aggregation pipeline and creating custom errors

Hello, when working with multi-stage aggregation pipelines and trying to make sure the data was received, in a case of an error, it is critical to know why the query yielded nothing and inform the user at which point in the pipeline the data stop appearing, for example resulting in an empty array altogether (initial $match found nothing), lookup failed (value not found on the external resource by the given criteria) etc. etc. Three questions stem from this dilemma:

  1. Is it possible to check for what was found/ done mid-pipeline? For example, is it possible after the $match stage to check if anything was found before proceeding to the next stage? And if not found:
  2. Is it possible to insert into the aggregation result array a custom value specific to that event (example an error object {error: “$Match did not find the product”}) 2. Is it possible to exit the pipeline early and return the said error?
  3. Perhaps not really tied to the original question, but since we are talking aggregation pipelines - how many times/ when should $project be run in the pipeline? Should it be repeated after every stage to keep the data as slim as possible in every stage, or should the $project be run at the end of the pipeline to shrink the final output?

Thank you very much