From 5b2ff74554f1c93aa8e8720a79d8a182bb7fc231 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 16 Oct 2014 23:16:04 -0400 Subject: [PATCH] Create errors with http-errors --- HISTORY.md | 1 + index.js | 21 ++------------------- package.json | 1 + 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 6b823f4..0a747cf 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,7 @@ unreleased ========== + * Create errors with `http-errors` * deps: debug@~2.1.0 - Implement `DEBUG_FD` env variable support * deps: mime-types@~2.0.2 diff --git a/index.js b/index.js index 7b62fca..ea000b7 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ - /*! * serve-index * Copyright(c) 2011 Sencha Inc. @@ -15,9 +14,9 @@ */ var accepts = require('accepts'); +var createError = require('http-errors'); var debug = require('debug')('serve-index'); -var http = require('http') - , fs = require('fs') +var fs = require('fs') , path = require('path') , normalize = path.normalize , sep = path.sep @@ -214,22 +213,6 @@ exports.plain = function(req, res, files){ res.end(buf); }; -/** - * Generate an `Error` from the given status `code` - * and optional `msg`. - * - * @param {Number} code - * @param {String} msg - * @return {Error} - * @api private - */ - -function createError(code, msg) { - var err = new Error(msg || http.STATUS_CODES[code]); - err.status = code; - return err; -}; - /** * Sort function for with directories first. */ diff --git a/package.json b/package.json index 3eb0b06..0d087e5 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "accepts": "~1.1.2", "batch": "0.5.1", "debug": "~2.1.0", + "http-errors": "~1.2.7", "mime-types": "~2.0.2", "parseurl": "~1.3.0" },