[errors] Add built in ErrnoError #9125
Labels
c++
Issues and PRs that require attention from people who are familiar with C++.
feature request
Issues that request new features to be added to Node.js.
System Errors are documented in the API Documentation and they are thrown all over the code, such examples are: util, spawn and dns. So I would like to propose to add built in
ErrnoError class
that can be used both by addon developers, node and even some user JavaScript code and to deprecate the currentSystem Errors
which are just augmentedErrors
.ErrnoError
constructor may accept two argumentserrno
of typeint
andsyscall
of typestring
and it should generate proper error message likesystem call X failed with Y errno code, {human readable meaning}
.ErrnoError
may also be separated in it's own header/source where errno codes are also mapped and as well available to addon writes then exposed to JavaScript, which is currently done in node_constants.And finally why I want such change to be made: to remove redundancy, as a node addon developer some times I need to define a macro that throws System Errors and there is no built in one so I have to either re-use the implementation from my previous project or created new one that slightly differs from the previous one - there is no standart way how Error instances are augmented, this redundancy can even be found in node's code itself: again in util, spawn and dns but is in JavaScript code not C++ ...
The text was updated successfully, but these errors were encountered: