diff --git a/HISTORY.md b/HISTORY.md index 7fd0375..76eb461 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,7 @@ unreleased ========== + * Pretty print JSON error response * perf: resolve file paths at start up 1.4.3 / 2016-01-17 diff --git a/index.js b/index.js index e253afa..53257b2 100644 --- a/index.js +++ b/index.js @@ -147,7 +147,7 @@ exports = module.exports = function errorHandler(options) { } else if (type === 'json') { var error = { message: err.message, stack: err.stack }; for (var prop in err) error[prop] = err[prop]; - var json = JSON.stringify({ error: error }); + var json = JSON.stringify({ error: error }, null, 2) res.setHeader('Content-Type', 'application/json; charset=utf-8') res.end(json); // plain text