Collect transaction data on failure

Hello,

My test case requires some transaction data to be captured from the application and dump into an excel file (which I have achieved using custom keyword). I have called the keyword at the end of my test step before closing of the browser assuming my test case has passed. However, if a test step fails in between this step is not executed and i lose my transaction data. Can someone suggest me how can i ensure to dump this data in excel even if my test case fails in between?

In selenium, I used to achieve this with the help of try… catch… blocks.

Appreciate the quick response.

Thanks.