Introduce ActionDispatch::DebugExceptions interceptors#23868
Conversation
|
r? @matthewd (@rails-bot has picked a reviewer for you, use r? to override) |
97c9795 to
bf198fe
Compare
There was a problem hiding this comment.
Can we get rid of the transitory @interceptors, and just call self.class.interceptors here?
There was a problem hiding this comment.
Injected it, so I can test it more easily – no need to keep track of the global state during the test run.
There was a problem hiding this comment.
🤷 I just think it would make sense to use the direct variable we will iterating on, instead of creating a shadow variable, that we won't even be changing.
|
As the maintainer of an exception notifier ( |
bf198fe to
fe88654
Compare
There was a problem hiding this comment.
Actually, this breaks the render_exception interface, and plugin authors already depend on it. I'm going with the duplicated code approach. Yeah, I like DRY code, but sometimes the duplication is so much better than breaking interfaces or leaking abstractions.
b6d25e4 to
24423aa
Compare
|
@gsamokovarov Is @rafaelfranca @matthewd Is there anything I can do to help move this forward? |
|
@tgxworld Yes, it is still monkey patching... You can make I still stand by the interceptors, though. They are super simple and provide what most of the plugins monkey patching |
|
The idea looks good to me. @gsamokovarov can you rebase it? |
95fd046 to
7c0d767
Compare
Plugins interacting with the exceptions caught and displayed by ActionDispatch::DebugExceptions currently have to monkey patch it to get the much needed exception for their calculation. With DebugExceptions.register_interceptor, plugin authors can hook into DebugExceptions and process the exception, before being rendered. They can store it into the request and process it on the way back of the middleware chain execution or act on it straight in the interceptor. The interceptors can be play blocks, procs, lambdas or any object that responds to `#call`.
7c0d767 to
d25fba8
Compare
|
@rafaelfranca I have rebased it. 👌 |
|
😍 Thank you @gsamokovarov and @rafaelfranca |
Plugins interacting with the exceptions caught and displayed by
ActionDispatch::DebugExceptionscurrently have to monkey patch it to getthe much needed exception for their calculation.
With
DebugExceptions.register_interceptor, plugin authors can hook intoDebugExceptionsand process the exception, before being rendered. Theycan store it into the request and process it on the way back of the
middleware chain execution or act on it straight in the interceptor.
The interceptors can be plain blocks, procs, lambdas or any object that
responds to
#call.You can see
web-consoleimplemented through the interceptor API here.Other plugin authors can benefit from this API as well. Most of the error
reporting plugins can use this.