Closed wagenet closed 5 years ago
I wonder if we took the current code
rescue_from Exception do |e|
handle_exception(e, show_raw_error: !!current_user.internal)
end
And threw a deprecation. Then document that customizing behavior is done with register_exception
instead of rescue_from
(so we can make more adjustments to the resulting payload, and do so with a class-based interface), and handle everything with ActionDispatch (which would grab the relevant registered exception and handle appropriately).
Does this sound feasible or am I off base?
I like the general idea, the main issue is that in the current implementation we only go through the GraphitiError handlers for JSON:API by default, with other content types being opt-in. So there could easily be a case where someone registers an exception but uses a different content type and it never gets used.
See #19 for a better overview of the problem.
rescue_from
bypasses all default error handling. Ideally, we'd provide a nice API to call from this.