Conversation
lib/internal/errors.js
Outdated
There was a problem hiding this comment.
Can we replace all of the rest args usage with a copy loop or whatever is fastest currently?
lib/internal/url.js
Outdated
There was a problem hiding this comment.
Can't this be placed at the top of the file?
lib/internal/util.js
Outdated
Add the internal/errors.js core mechanism.
Update most of the errors to use internal/errors. Purposefully leaves two errors in place to be updated later.
|
@mscdex ... updated! |
|
Can. Kept it local to the error since it's the only instance of use. On Monday, October 24, 2016, Brian White notifications@github.com wrote:
|
|
|
||
| // Utility function for registering the error codes. | ||
| function E(sym, val) { | ||
| exports[Symbol.for(String(sym).toUpperCase())] = |
There was a problem hiding this comment.
Since this is using the global symbol registry, perhaps we should add a NODE_ prefix to the key.
| // to the readable-stream standalone module. If the logic here changes at all, | ||
| // then those also need to be checked. | ||
|
|
||
| const kCode = Symbol('code'); |
| const kCode = Symbol('code'); | ||
|
|
||
| class NodeError extends Error { | ||
| constructor(key /**, ...args **/) { |
There was a problem hiding this comment.
I think the overhead of rest parameters is negligible here.
Testcase: https://jsperf.com/custom-error-with-rest-params
|
|
||
| if (!NativeModule.exists(id)) { | ||
| throw new Error(`No such native module ${id}`); | ||
| const errors = require('internal/errors'); |
There was a problem hiding this comment.
nit: const {Error} = require('internal/errors');
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
errors
Description of change
A more incremental version of #6573.
Introduces the internal/errors.js module and begins updating errors in the
internal modules to use it. This is intentionally incomplete. Other errors can
be migrated over to this incrementally.
This is semver-major because several of the error messages are updated
in the process.