npm / npm-registry-client

http://npm.im/npm-registry-client
ISC License
264 stars 108 forks source link

request: don't return error as String #113

Closed othiym23 closed 9 years ago

othiym23 commented 9 years ago

This bug has been lurking for a really long time, but was only recently exposed by changes to the registry architecture that make it more common for the registry to return a 404 without a body.

Fixes: #112

r: @zkat (for inclusion in whatever version of npm-registry-client includes the Team API changes, probably?)

alanshaw commented 9 years ago

Other errors from this module are augmented with a code, statusCode and pkgid (https://github.com/npm/npm-registry-client/blob/a8d3193832487fb2e6b5015e30d15fe1b15f48e2/lib/request.js#L251-L253). Should we do the same here for consistency?

From @othiym23:

Probably all of the logic related to initializing the error should be hoisted into a helper function and then used everywhere we're returning errors, as we do elsewhere in the npm code base.

othiym23 commented 9 years ago

@zkat I've made the changes suggested in the preceding comment, and pending your review, this is ready for merge (either by you or by me, you pick). Thanks for the review, @alanshaw!

zkat commented 9 years ago

:sheep:

zkat commented 9 years ago

Merged as of efe7e5a