Open dhempy opened 4 years ago
@dhempy it does seem useful to provide a list of exception classes that should not be caught by Better Errors. Something like ignored_exception_classnames
? (I would like to rename ignored_classes
to be more meaningful.)
I suppose it also could be possible to do the same thing with path matching, but I think exception classnames would be more broadly useful.
I have the same requirement. I would like to disable better_errors for all requests to our API controllers, but have better_errors work for non-API controllers. In development I still want the API controller to return the same error response it would in production so I can do development on the error handling of API clients.
@k1w1 Better Errors will only change the response for an unhandled exception. If you want development to act the same as production, it would be best to add a rescue_from
handler to your controller. This is good practice anyway so you can report/log your exception and control the response.
Now that I've read your comment, I realize this might be the answer that @dhempy might be looking for.
Thanks, that makes perfect sense now. I just need to rescue_from
all errors to control the response.
I'd like for better_errors to not do anything for a given endpoint or controller.
For example, I have
UptimeController#example_error
that intentionally raises an error to aid in system monitoring. This works fine in prod, but in dev better_errors does its job and returns a better error message.But I don't want it to. I want to actually see the error returned to the browser, as it will in prod.
I've tried: BetterErrors.ignored_classes = ['ActionDispatch::Request', 'ActionDispatch::Response', 'UptimeController']
...but I guess that only affects inspection, not rescuing.
Is it currently possible to suppress better_errors for one endpoint?
If not, would this be useful to others? I don't mind taking it on, if the community doesn't think it's a dumb idea.