aserafin / grape_logging

Request logging for Grape!
MIT License
147 stars 76 forks source link

Don't fail when response is `nil` #19

Closed rngtng closed 8 years ago

rngtng commented 8 years ago

As of https://github.com/ruby-grape/grape/pull/1240 the #after hook is called on even when exception is raised. This breaks grape_logging which assumes response, (@app_response) to be set see: https://github.com/aserafin/grape_logging/blob/master/lib/grape_logging/middleware/request_logger.rb#L36

See https://github.com/ruby-grape/grape/issues/1265 for discussion

rngtng commented 8 years ago

related: https://github.com/aserafin/grape_logging/pull/10 (but doesn't actually solve the issue)

guizmaii commented 8 years ago

Do you have an idea on how to solve this ? I'm working on this problem in my fork.

rngtng commented 8 years ago

well just check on the value of response;

a dirty hack would be:

response.try(:status)

or better

status: (response.nil? ? nil : response.status) # or 'error' instead of nil
guizmaii commented 8 years ago

Ok thanks. It's done in my PR #16

aserafin commented 8 years ago

@rngtng should be fixed since I merged #16