mirror of
https://github.com/samsonjs/grape_logging.git
synced 2026-03-25 08:55:47 +00:00
Since the Grape v0.14.1, the after callback is always called, so response could be nil if the called fail with an exception
This commit is contained in:
parent
fe72aa1a15
commit
ef946bf7fe
2 changed files with 8 additions and 4 deletions
|
|
@ -2,9 +2,13 @@ module GrapeLogging
|
|||
module Loggers
|
||||
class Response < GrapeLogging::Loggers::Base
|
||||
def parameters(request, response)
|
||||
{
|
||||
response: serialized_response_body(response)
|
||||
}
|
||||
if response
|
||||
{
|
||||
response: serialized_response_body(response)
|
||||
}
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ module GrapeLogging
|
|||
protected
|
||||
def parameters
|
||||
{
|
||||
status: response.status,
|
||||
status: response.try(:status),
|
||||
time: {
|
||||
total: total_runtime,
|
||||
db: db_runtime,
|
||||
|
|
|
|||
Loading…
Reference in a new issue