Skip to content

Commit

Permalink
Pretty print JSON error response
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jun 17, 2016
1 parent 4f3885b commit cb669ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unreleased
==========

* Pretty print JSON error response
* deps: accepts@~1.3.3
- deps: mime-types@~2.1.11
- deps: negotiator@0.6.1
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb669ce

Please sign in to comment.