'How to get information about exception thrown in AfterScenario hook in Gauge framework?

I'm using Gauge framework with Java as part of the automation suite. We get the information whether a scenario is failing or not from the isFailing flag in executionContext.getCurrentScenario().
But can we get the reason it is failing - if assertion failed or some exception occurred, etc. - in AfterScenario?

There is a executionContext.getCurrentStep().getErrorMessage() and executionContext.getCurrentStep().getStackTrace() but they don't seem to give the required failed information. Is there any way we can do it?

Came across a similar question in cucumber framework here: How to get the exception that was thrown when a Cucumber test failed in Java? Can something similar be applied?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source