Skip to content

Commit

Permalink
Refactor: extract variable and reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
ggalmazor committed Sep 24, 2024
1 parent 1d44f23 commit 5ce0fbb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/mailgun/exceptions/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def initialize(message = nil, response = nil)
end

begin
api_message = JSON.parse(response.body)['message'] || JSON.parse(response.body)['Error']
json = JSON.parse(response.body)
api_message = json['message'] || json['Error']
rescue JSON::ParserError
api_message = response.body
rescue NoMethodError
Expand Down

0 comments on commit 5ce0fbb

Please sign in to comment.