Skip to content

Commit

Permalink
if api return 400 code with rest_post_invalid_page_number return empt…
Browse files Browse the repository at this point in the history
…y response
  • Loading branch information
distroid committed Jul 17, 2017
1 parent 4c11ec2 commit 7aa6976
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/wp/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ def get_request(resource, query = {})

response = Client.get(path, options)
if response.code != 200
return [[], response.headers] if response.parsed_response['code'] == 'rest_post_invalid_page_number'
raise WP::API::ResourceNotFoundError.new('Invalid HTTP code (' + response.code.to_s + ') for ' + path)
elsif response.parsed_response.empty? && should_raise_on_empty
raise WP::API::ResourceNotFoundError.new('Empty responce for ' + path)
else
[ response.parsed_response, response.headers ]
[response.parsed_response, response.headers]
end
end

Expand Down

0 comments on commit 7aa6976

Please sign in to comment.