Use http-errors module for creating errors

parent 35e0568d
2.x
===
* Use `http-errors` module for creating errors
* Use `utils-merge` module for merging objects
* deps: body-parser@~1.9.0
- include the charset in "unsupported charset" error message
......
......@@ -9,6 +9,7 @@
* Module dependencies.
*/
var createError = require('http-errors');
var deprecate = require('depd')('connect');
var parseBytes = require('bytes');
var utils = require('../utils');
......@@ -52,7 +53,7 @@ module.exports = function limit(bytes){
req._limit = true;
// limit by content-length
if (len && len > bytes) return next(utils.error(413));
if (len && len > bytes) return next(createError(413));
// limit
if (brokenPause) {
......
......@@ -12,6 +12,7 @@
var bytes = require('bytes');
var cookieParser = require('cookie-parser');
var createError = require('http-errors');
var deprecate = require('depd')('connect');
var http = require('http')
, crypto = require('crypto')
......@@ -74,6 +75,9 @@ exports.error = function(code, msg){
return err;
};
exports.error = deprecate.function(exports.error,
'utils.error: use http-errors npm module instead');
/**
* Return md5 hash of the given string and optional encoding,
* defaulting to hex.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment