Permalink
Browse files

Send headers in http errors, fixes #81

  • Loading branch information...
1 parent b1fdb8f commit f5607be474d436190349c4b7a25dbe71bc219293 @pksunkara committed Dec 23, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/octonode/client.coffee
View
8 src/octonode/client.coffee
@@ -21,7 +21,7 @@ Search = require './search'
# Specialized error
class HttpError extends Error
- constructor: (@message, @statusCode) ->
+ constructor: (@message, @statusCode, @headers) ->
# Initiate class
class Client
@@ -86,13 +86,13 @@ class Client
errorHandle: (res, body, callback) ->
# TODO: More detailed HTTP error message
- return callback(new HttpError('Error ' + res.statusCode, res.statusCode)) if Math.floor(res.statusCode/100) is 5
+ return callback(new HttpError('Error ' + res.statusCode, res.statusCode, res.headers)) if Math.floor(res.statusCode/100) is 5
try
body = JSON.parse(body || '{}')
catch err
return callback(err)
- return callback(new HttpError(body.message, res.statusCode)) if body.message and res.statusCode is 422
- return callback(new HttpError(body.message, res.statusCode)) if body.message and res.statusCode in [400, 401, 404]
+ return callback(new HttpError(body.message, res.statusCode, res.headers)) if body.message and res.statusCode is 422
+ return callback(new HttpError(body.message, res.statusCode, res.headers)) if body.message and res.statusCode in [400, 401, 404]
callback null, res.statusCode, body, res.headers
# Github api GET request

0 comments on commit f5607be

Please sign in to comment.