In my front end, I want to be able to display an error to the user if they can't perform a certain transaction. When I use 'try catch' when calling a function that fails, it catches: "Error: cannot estimate gas; transaction may fail or may require manual gas limit..." which is all one string. I noticed that in the console I get "MetaMask - RPC Error: execution reverted: ..." which is an object that contains the information I want but I can't seem to get the object in my front end to display it's message. Is there a way to easily show why a transaction reverted in the front end?
Currently I do:
try{
await contract.someFunction()
}catch(e){
}
Which catches the long string and not the metamask object