Skip to content
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

Less Obtuse Error Messages #212

Closed
xjamundx opened this issue Dec 27, 2014 · 12 comments
Closed

Less Obtuse Error Messages #212

xjamundx opened this issue Dec 27, 2014 · 12 comments
Labels
discuss Issues opened for discussions and feedbacks. fs Issues and PRs related to the fs subsystem / file system.

Comments

@xjamundx
Copy link
Contributor

fs.readFile('./notfound', function(err, data) {
   throw err; // Uncaught Error: ENOENT, open './notfound'
});

I was hoping we could change this to something awesome like "File not found './notfound'". In fact, I have a hunch there are a lot of obscure error messages that might be made into something a bit more user friendly. If you'd like me to take a serious stab at cataloging these I can, but I have a hunch this is enough to start the discussion.

Thanks ;-)

@brendanashworth
Copy link
Contributor

For reference: errno.h

I'm not sure whether they're the official messages for the error codes, but "No such file or directory" sounds a lot better than ENOENT, especially to somebody who hasn't touched a language with those error codes. 👍

@abenhamdine
Copy link

👍

@algesten
Copy link

However for people that are used to errno.h any "user friendly" variant should contain the original code to not confuse matters. "ENOENT: No such file or directory".

@sonewman
Copy link
Contributor

linking this to: #92

@xjamundx
Copy link
Contributor Author

So I'm not super expert at node under the hood, but here's what I found about how this works.

fs.readFile calls fs.open which calls process.binding('fs') which at some point references https://github.com/libuv/libuv/ which is split into unix and win code-paths, which both handle errors differently.

https://github.com/libuv/libuv/blob/v1.x/src/win/fs.c

On the windows side these are translated into some sort of unixy error thing here:
https://github.com/libuv/libuv/blob/v1.x/src/win/error.c#L67

On the Unix side we appear to just be bubbling up the raw errors.
https://github.com/libuv/libuv/blob/v1.x/src/unix/fs.c#L180

It's unclear to me if node would take seriously the chance to shield all of the low level errors from the average devs and if they did if it would happen at the libuv level or up in actual node-land.

/ramblings

@algesten
Copy link

@xjamundx I would imagine the task is to "decorate" well known error codes with some user friendly text, but I'm very much against obfuscating the actual underlying code, and I'd imagine some codes would hit the user raw, without any decoration. To me that's node-land, not libuv. Having said that, I'm actually mildly against the original suggestion: devs should know what they're doing. If they don't understand the error, RTFM.

@badeend
Copy link

badeend commented Dec 30, 2014

+1 for specifying the error code and error message. That way both experts and newcomers know what's up.

@algesten I think there is a difference between not knowing what you're doing and not being able to memorize all the error codes. Especially on Windows; many of the error codes seem foreign, because libuv translates them to a UNIX variant.

@chrisdickinson
Copy link
Contributor

Currently, the best place to go to read about the error codes iojs returns is man 2 intro on the CLI. This information should be linked in the iojs docs. I need to tidy nodejs/node-v0.x-archive#8114 up and re-send it to this repo. Mea culpa!

@vkurchatkin vkurchatkin added the fs Issues and PRs related to the fs subsystem / file system. label Jan 23, 2015
@Fishrock123 Fishrock123 added the discuss Issues opened for discussions and feedbacks. label Feb 13, 2015
@frankrousseau
Copy link

+1 about having more explicit error messages. Current error logging makes debugging slower. The new io.js documentation about error codes is a big step forward. But I think it should be included with the error output.

Info: I'm ready to code if needed.

@piscisaureus
Copy link
Contributor

bc2c85c

@piscisaureus
Copy link
Contributor

Closing this issue because the error messages for fs have been improved, which was what the TS asked for.
Please create a new issue if you run into unclear error messages in other areas.

@xjamundx
Copy link
Contributor Author

Wait @piscisaureus you fixed this? Just based on my issue? Seriously, that's amazing!

jasongin pushed a commit to jasongin/nodejs that referenced this issue Mar 29, 2017
These APIs will be redesigned and added into the master branch after our main PR lands there.

See nodejs/abi-stable-node#204 to see progress on the redesigned APIs.
boingoing added a commit to boingoing/node that referenced this issue Apr 6, 2017
These APIs will be redesigned and added into the master branch after our main PR lands there.

See nodejs/abi-stable-node#204 to see progress on the redesigned APIs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Issues opened for discussions and feedbacks. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests