express icon indicating copy to clipboard operation
express copied to clipboard

next()ing an error with json content type wont return formatted error

Open tdfairbrother opened this issue 15 years ago • 2 comments

jQuery $.ajax({url:"http://localhost:3000/nodeapi/error", dataType:'json'})

Express app.get('/error', function(req, res, next) { next(new Error('my custom error')) })

Will produce {"error":{}}

In development mode only.

It appears the line 78 of errorHandler.js does the following.

var json = JSON.stringify({ error: err });

Try the following in a browser to see the same problem JSON.stringify(new Error('test'))

Cheers,

Tim

tdfairbrother avatar Dec 02 '11 04:12 tdfairbrother

yeah the v8 update in 0.6.x makes the error properties non-enumerable, this is fixed however I need to release

tj avatar Dec 02 '11 16:12 tj

This issue has been inactive for over 4 months so I'm closing it. If you think it's still an issue re-open.

  • tjbot

tj avatar Jun 17 '12 02:06 tj