Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Continuing a thought: JS-level util.errnoException #1689

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

I noticed new stubbed lib/ code similar to my needs; researched and
then started this change;

two typos fixed, stub consolidated and moved to util.js and expanded;
usage areas indicated; test file started

@tshinnic tshinnic Continuing a thought: JS-level util.errnoException
I noticed new stubbed lib/ code similar to my needs; researched and
then started this change;

**two typos fixed**, stub consolidated and moved to util.js and expanded;
usage areas indicated; test file started
d441775

I needed something that would create an Error object similar to what is
produced by a system error, e.g. ENOENT, where e.code, e.errno, and
e.message were filled in as would be expected.

I looked around and noticed these duplicate stubbed routines along with comments
indicating a wish for a JS-level equivalent for src/node.cc ErrnoException().

While seeing how the stubs were used I noticed two typos, as noted in change.

I've relocated a single copy of the stub code into lib/util.js. I don't
know if this is the appropriate place.

I've expanded the stub to handle 'message' and 'path' arguments.

I've also made a stab at resolving a string errno to the errno number.
There is a potential for confusion, but the convention seems to be
well-observed that err.errno is a number and err.code is the error
name string. I'm fudging by using lookup from constants.

The problem of resolving error names to numbers and vice-versa, along
with the problem/potential for supplying the correct default message
ala strerror() needs discussion. There is currently no nice way to
supply error names and descriptions to JS-level code.

perhaps superseded by #2695

Can one of the admins verify this patch?

Most of this work was done in 0161ec8

@tjfontaine tjfontaine closed this Feb 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment