Skip to content

Commit

Permalink
http: more descriptive setHeader errors
Browse files Browse the repository at this point in the history
PR-URL: #480
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
  • Loading branch information
qzaidi authored and Stephen Belanger committed Jan 30, 2015
1 parent cbc1262 commit cf3e908
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ function storeHeader(self, state, field, value) {

OutgoingMessage.prototype.setHeader = function(name, value) {
if (typeof name !== 'string')
throw new TypeError('"name" should be a string');
throw new TypeError('`name` should be a string in setHeader(name, value).');
if (value === undefined)
throw new Error('"name" and "value" are required for setHeader().');
throw new Error('`value` required in setHeader("' + name + '", value).');
if (this._header)
throw new Error('Can\'t set headers after they are sent.');

Expand All @@ -327,7 +327,7 @@ OutgoingMessage.prototype.setHeader = function(name, value) {

OutgoingMessage.prototype.getHeader = function(name) {
if (arguments.length < 1) {
throw new Error('`name` is required for getHeader().');
throw new Error('`name` is required for getHeader(name).');
}

if (!this._headers) return;
Expand All @@ -339,7 +339,7 @@ OutgoingMessage.prototype.getHeader = function(name) {

OutgoingMessage.prototype.removeHeader = function(name) {
if (arguments.length < 1) {
throw new Error('`name` is required for removeHeader().');
throw new Error('`name` is required for removeHeader(name).');
}

if (this._header) {
Expand Down

0 comments on commit cf3e908

Please sign in to comment.