Skip to content

Commit

Permalink
Return Error documentation url if error data is a hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyw committed Mar 3, 2014
1 parent 4adba81 commit 52efb2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/octokit/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(response=nil)
#
# @return [String]
def documentation_url
data[:documentation_url] if data
data[:documentation_url] if data.is_a? Hash
end

# Returns most appropriate error for 401 HTTP status code
Expand Down
10 changes: 10 additions & 0 deletions spec/octokit/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,16 @@
expect(e.documentation_url).to eq("http://developer.github.com/v3")
end
end

it "handles an error response with an array body" do
stub_get('/user').to_return \
:status => 500,
:headers => {
:content_type => "application/json"
},
:body => [].to_json
expect { Octokit.get('/user') }.to raise_error Octokit::ServerError
end
end

it "knows the difference between unauthorized and needs OTP" do
Expand Down

0 comments on commit 52efb2f

Please sign in to comment.