Hello @Satyam Chauhan ,
the simplest way is sending separate messages based on exceptions or error flow inside the modules.
These messages are preferably sent over a separate output. These 'error' outputs are routed on the edge to $upstream.
Notice, these messages have probably a different body format compared to the regular telemetry. I suggest adding an application property telling the body contains an exception/success/failure.
When these 'error' messages arrive in the IoT Hub, you can route them to a custom/separate endpoint, eg. an Event Hub.
From there you can respond in real-time if these 'error' messages arrive.
It's a good idea to store these message in a blob storage or Azure Data Explorer for historical purposes.