src/HTTPError.js
function HTTPError() {
	var args = Array.prototype.slice.call(arguments);
	if(!(this instanceof HTTPError)) {
		if(args.length === 1) {
			return new HTTPError(args[0]);
		} else if(args.length === 2) {
			return new HTTPError(args[0], args[1]);
		} else if(args.length === 3) {
			return new HTTPError(args[0], args[1], args[2]);
		} else {
			throw new TypeError("Too many arguments (" + args.length + ") for new HTTPError()");
		}
	}

	var headers, msg, code;
	ARRAY(args).forEach(function(arg) {
		if(typeof arg === 'object') {
			headers = arg;
		}
		if(typeof arg === 'string') {
			msg = arg;
		}
		if(typeof arg === 'number') {
			code = arg;
		}
	});

	code = code || 500;
	msg = msg || (''+code+' '+require('http').STATUS_CODES[code]);
	headers = headers || {};

	Error.call(this);
	Error.captureStackTrace(this, this);
	this.code = code;
	this.message = msg;
	this.headers = headers;
}
function HTTPError() {
	var args = Array.prototype.slice.call(arguments);
	if(!(this instanceof HTTPError)) {
		if(args.length === 1) {
			return new HTTPError(args[0]);
		} else if(args.length === 2) {
			return new HTTPError(args[0], args[1]);
		} else if(args.length === 3) {
			return new HTTPError(args[0], args[1], args[2]);
		} else {
			throw new TypeError("Too many arguments (" + args.length + ") for new HTTPError()");
		}
	}

	var headers, msg, code;
	ARRAY(args).forEach(function(arg) {
		if(typeof arg === 'object') {
			headers = arg;
		}
		if(typeof arg === 'string') {
			msg = arg;
		}
		if(typeof arg === 'number') {
			code = arg;
		}
	});

	code = code || 500;
	msg = msg || (''+code+' '+require('http').STATUS_CODES[code]);
	headers = headers || {};

	Error.call(this);
	Error.captureStackTrace(this, this);
	this.code = code;
	this.message = msg;
	this.headers = headers;
}
function HTTPError ( ) { var args = Array . prototype . slice . call ( arguments ) ; if ( ! ( this instanceof HTTPError ) ) { if ( args . length === 1 ) { return new HTTPError ( args [ 0 ] ) ; } else if ( args . length === 2 ) { return new HTTPError ( args [ 0 ] , args [ 1 ] ) ; } else if ( args . length === 3 ) { return new HTTPError ( args [ 0 ] , args [ 1 ] , args [ 2 ] ) ; } else { throw new TypeError ( "Too many arguments (" + args . length + ") for new HTTPError()" ) ; } } var headers , msg , code ; ARRAY ( args ) . forEach ( function ( arg ) { if ( typeof arg === 'object' ) { headers = arg ; } if ( typeof arg === 'string' ) { msg = arg ; } if ( typeof arg === 'number' ) { code = arg ; } } ) ; code = code || 500 ; msg = msg || ( '' + code + ' ' + require ( 'http' ) . STATUS_CODES [ code ] ) ; headers = headers || { } ; Error . call ( this ) ; Error . captureStackTrace ( this , this ) ; this . code = code ; this . message = msg ; this . headers = headers ; }
Exception type for HTTP errors
Exception type for HTTP errors