Uh oh!
There was an error while loading. Please reload this page.
handle undefined statusCode with an error - #3358
Conversation
dougwilson
commented
Jul 7, 2017
dougwilson
left a comment
There was a problem hiding this comment.
Thanks for putting this together! Besides the comment to check out if this is similar to a previous PR, if you believe it is not, please feel free to update the PR with tests for the new validations.
dougwilson
commented
Jul 7, 2017
I tried your example, and I'm not sure what is happening, but I'm seeing some very different things that what you reported. Here are the two biggest differences:
|
ghinks
commented
Jul 7, 2017
this is not quite a duplicate of #3143 |
ghinks
commented
Jul 7, 2017
ok, what is your current version of express haha. I have an example at https://github.com/ghinks/express-status-code-error-example.git |
ghinks
commented
Jul 8, 2017
Ok, I understand the issue now. res.status(undefined).send('not ok'); where as newer node versions ( I tested with 6.8.0 ) give which is a lot more helpful. So node core fixed what I wanted to do in express which was give a meaningful error when an undefined was sent. |
dougwilson
commented
Jul 10, 2017
Ah, sorry, didn't think Node.js used to have a bad message. Yes, I was using 6.11.0 and Express 4.15.3 |
description
We can bettor handle the error case when an undefined is sent as the status code in the response as it currently goes down to the node layer and does not give a clear error.
If the status code is undefined when you call
you get an error OF COURSE. But I think we could handle this case a bit more clearly than the stack trace allows.
instructions to reproduce
npm start
then hit the end point
The following is what you currently see if you send an undefined statusCode in a response.
I think that something with
is maybe an improvement.