Created
August 16, 2010 16:04
-
-
Save nrstott/527190 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return when(this.httpClient.request(opts), function success(resp) { | |
var body = ""; | |
return when(resp.body.forEach(function(chunk) { body += chunk; }), function() { | |
var val = JSON.parse(body); | |
if (resp.status >= 400) { | |
try { | |
val = JSON.parse(body); | |
} catch (err) { | |
val = { error: 'ParseError', reason: body } | |
} | |
finally { | |
throw val; | |
} | |
} | |
return val; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment