-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle undefined statusCode with an error #3358
handle undefined statusCode with an error #3358
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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:
|
this is not quite a duplicate of #3143 |
ok, what is your current version of express haha. I have an example at https://github.com/ghinks/express-status-code-error-example.git |
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. |
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.