Skip to content

Commit

Permalink
Faraday::Logging::Formatter#error: Prevent NoMethodError when receive…
Browse files Browse the repository at this point in the history
…d anything other than Faraday::Error.
  • Loading branch information
epaew authored and olleolleolle committed Nov 14, 2022
1 parent 5d28006 commit 93affec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/faraday/logging/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def error(error)
error_log = proc { error.full_message }
public_send(log_level, 'error', &error_log)

log_headers('error', error.response_headers) if log_headers?(:error)
log_body('error', error.response_body) if error.response_body && log_body?(:error)
log_headers('error', error.response_headers) if error.respond_to?(:response_headers) && log_headers?(:error)
return unless error.respond_to?(:response_body) && error.response_body && log_body?(:error)

log_body('error', error.response_body)
end

def filter(filter_word, filter_replacement)
Expand Down

0 comments on commit 93affec

Please sign in to comment.