runAfterStepHooks should allow the user to replace an error with a nil or another error #633
Labels
⚡ enhancement
Request for new functionality
Content-Length: 212985 | pFad | http://github.com/cucumber/godog/issues/633
B1Fetched URL: http://github.com/cucumber/godog/issues/633
Alternative Proxies:
See PR #634
🤔 What's the problem you're trying to solve?
I need the ability to installa hook that either knocks out an error returned from a step, or completely replaced the error returned from a step.
The current runAfterStepHooks function does not make this possible as it has a guard expression that prevents me knocking out a current error, and a separate guard expression that prevents me substituting a different error (does an append instead).
! To be honest I think it would be better for godog just to change AfterStep to make it do what my PostStep does and break compat.
✨ What's your proposed solution?
I can't see a backwards compat solution so I will raise a PR adding a "PostStepHook" and runPostStepHooks() which is a more open api than the existing PostStepHook.
⛏ Have you considered any alternatives or workarounds?
Alternatively, we can break backwards compatibility - we could replace the existing runAfterStepHooks with the impl I have in runPostStepHooks in my PR.
The two impls are below for your convenience....
📚 Any additional context?
It is unfortunate that the existing AfterStep hook make the assumptions it does in runAfterStepHooks.
"AfterStep" doco says
// It may be convenient to return a different kind of error
// in order to print more state details which may help
... but the current impl doesn't allow me to return a "different" error, just an "additional" error.
The text was updated successfully, but these errors were encountered: