contract TryCatcher { event ReturnDataEvent(bytes someData); event CatchStringEvent(string someString); event SuccessEvent(); // ... function execute() public { try externalContract.someFunction() { emit SuccessEvent(); } catch Error(string memory revertReason) { emit CatchStringEvent(revertReason); } catch (bytes memory returnData) { emit ReturnDataEvent(returnData); } } }
contract TryCatcher { event PanicErrorEvent(uint errorCode); event CatchStringEvent(string someString); event SuccessEvent(); // ... function execute() public { try externalContract.someFunction() { emit SuccessEvent(); } catch Error(string memory revertReason) { emit CatchStringEvent(revertReason); } catch Panic(uint errorCode) { emit PanicErrorEvent(errorCode); } } }