Skip to content

Commit

Permalink
Emit errors for anything in init so that it is catchable in a redirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Oct 28, 2012
1 parent 59cf5e6 commit 7a16286
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ Request.prototype.init = function (options) {
}

if (!self.uri) {
throw new Error("options.uri is a required argument")
// this will throw if unhandled but is handleable when in a redirect
return self.emit('error', new Error("options.uri is a required argument"))
} else {
if (typeof self.uri == "string") self.uri = url.parse(self.uri)
}
Expand Down Expand Up @@ -301,7 +302,7 @@ Request.prototype.init = function (options) {
;
self.httpModule = httpModules[protocol] || defaultModules[protocol]

if (!self.httpModule) throw new Error("Invalid protocol")
if (!self.httpModule) return this.emit('error', new Error("Invalid protocol"))

if (options.ca) self.ca = options.ca

Expand Down

0 comments on commit 7a16286

Please sign in to comment.