Skip to content

Commit

Permalink
combine early return condition into should return helper
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsaab committed Jan 31, 2025
1 parent c315710 commit 19d502d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/slack/web/faraday/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ def response_content_type_is_a_string?(env)

def should_return?(env)
body = env.body
(env.success? && body.is_a?(String) && response_content_type_is_a_string?(env)) || !body || body['ok']
return true if !env.success?
return true if env.success? && body.is_a?(String) && response_content_type_is_a_string?(env)
return true if !body || body['ok']
return false
end

def on_complete(env)
throw_if_too_many_requests(env)
throw_if_response_is_invalid_json(env)

return unless env.success?

body = env.body
return if should_return?(env)

Expand Down

0 comments on commit 19d502d

Please sign in to comment.