Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
More debuggery
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed May 17, 2010
1 parent 7b11151 commit 0df342b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/utils/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,28 @@ function request (method, where, what, cb) {
request.addListener("response", function (response) {
// if (response.statusCode !== 200) return cb(new Error(
// "Status code " + response.statusCode + " from PUT "+where))
log("got response", "registry")
var data = ""
response.setEncoding ? response.setEncoding("utf8")
: response.setBodyEncoding("utf8")
response.addListener("data", function (chunk) { data += chunk })
response.addListener("end", function () {
log("got response", "registry")
var parsed
try {
parsed = JSON.parse(data)
} catch (ex) {
ex.message += "\n" + data
log("error parsing json", "registry")
return cb(ex, null, data, response)
}
if (parsed && parsed.error) return cb(new Error(
parsed.error + (" "+parsed.reason || "")), parsed, data, response)
cb(null, parsed, data, response)
})
})
if (what) request.write(what, "ascii")
if (what) {
log("writing", "registry")
request.write(what)
}
request.end()
}

Expand Down

0 comments on commit 0df342b

Please sign in to comment.