How to use handleRevert in web3 for fetching transaction reverting reason

Hi Community,

I'm trying to fetch the transaction reverting reason.

https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html?highlight=handlerevert

I'm not able to use it correctly. If someone can help me in this query.

Thanks

Check this out https://web3js.readthedocs.io/en/v1.2.11/callbacks-promises-events.html

Use .on('error', function(error){ ... })