-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Middleware loggers unaware about rescue_from handlers #1734
Comments
Care to provide a more detailed example with some code maybe? |
@dblock thank you for listening but i think i figured it out myself. I've inserted now the logger before Grape::Middleware::Error which handles the rescue_from blocks and then passes the exception with the right status code to the logger. see: aserafin/grape_logging#45 (comment) It was tricky to figure out the actual middleware stack. I just saw it in a stacktrace while debugging. It would be nice to have a convinient rake task which prints out the whole middleware stack just like in rails + some more detailed documentation about it. |
Maybe you can contribute something? At least some documentation as well as details of how you solved this here. You can then close the issue? |
The solution is already linked. |
Yes, please PR a change to README. |
As far as i digged in the code it seems that loggers realized as middleware are not aware of changes to exceptions made by rescue_from handlers.
I stumbled upon this as i saw log entries with a wrong statuscode in my application. I am catching an UnauthorizedException in a rescue_from block and setting the desired statuscode with
error! e, 401
. It works as expected but produces a 500 log entry.Maybe worth a discussion about possible solutions?
The text was updated successfully, but these errors were encountered: