Skip to content

Commit

Permalink
Complain about status code before content type.
Browse files Browse the repository at this point in the history
GitHub currently returns 500 errors as HTML. When we encountered this, the
error message referred to the content type rather than the status code. Now we
check the status code first, so errors are more informative.

Signed-off-by: Felipe Coury <felipe.coury@gmail.com>
  • Loading branch information
runpaint authored and fcoury committed Apr 21, 2009
1 parent 24f9824 commit cbcda56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/octopi.rb
Expand Up @@ -98,13 +98,13 @@ def submit(path, params = {}, format = "yaml", &block)
end
query = login ? { :login => login, :token => token } : {}
resp = yield(path, query.merge(params), format)
raise APIError,
"GitHub returned status #{resp.code}" unless resp.code.to_i == 200
# FIXME: This fails for showing raw Git data because that call returns
# text/html as the content type. This issue has been reported.
ctype = resp.headers['content-type'].first
raise FormatError, [ctype, format] unless
ctype.match(/^#{CONTENT_TYPE[format]};/)
raise APIError,
"GitHub returned status #{resp.code}" unless resp.code.to_i == 200
if format == 'yaml' && resp['error']
raise APIError, resp['error'].first['error']
end
Expand Down

0 comments on commit cbcda56

Please sign in to comment.