Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

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

Closed
wants to merge 1 commit into from

Conversation

tshinnic
Copy link

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

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
Copy link
Author

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.

@tjfontaine
Copy link

perhaps superseded by #2695

@Nodejs-Jenkins
Copy link

Can one of the admins verify this patch?

@tjfontaine
Copy link

Most of this work was done in 0161ec8

@tjfontaine tjfontaine closed this Feb 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants