-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
Better error handling for sendFile #3582
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.
Nice! Can you add a test that tests the condition in which you were encountering? That way we don't accidentally regress.
lib/response.js
Outdated
if (!path) { | ||
throw new TypeError('path argument is required to res.sendFile'); | ||
if (typeof path !== 'string') { | ||
throw new TypeError('path must be string'); |
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.
Also, can you add back res.sendFile
to the message? Helps people know what function the issue was to.
if you pass something other than valid string like sendFile({}) you get: TypeError: path.substring is not a function. which is kind of confusing, so instead now you getting: path must be string |
Makes sense. Just add a test for that so we have it there to not regress from a refactor 👍 |
@dougwilson all test are passing on my system |
The build failures seemed unrelated, I restarted the two failed builds... |
so you don't get confusing errors like: function substring not found or something