-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
lib: make lazyDOMException more common #39105
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ const { | |
| } = primordials; | ||
|
|
||
| const { | ||
| hideStackFrames, | ||
| codes: { | ||
| ERR_INVALID_ARG_TYPE, | ||
| ERR_NO_CRYPTO, | ||
|
|
@@ -441,6 +442,13 @@ function createDeferredPromise() { | |
| return { promise, resolve, reject }; | ||
| } | ||
|
|
||
| let DOMException; | ||
| const lazyDOMException = hideStackFrames((message, name) => { | ||
| if (DOMException === undefined) | ||
| DOMException = internalBinding('messaging').DOMException; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's good to hoist this out of the crypto util and make it more universal in the code base, but I am wondering, why do we want to make this lazy?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably to avoid building the JS function until we're on the error path?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return new DOMException(message, name); | ||
| }); | ||
|
|
||
| module.exports = { | ||
| assertCrypto, | ||
| cachedResult, | ||
|
|
@@ -457,6 +465,7 @@ module.exports = { | |
| isError, | ||
| isInsideNodeModules, | ||
| join, | ||
| lazyDOMException, | ||
| normalizeEncoding, | ||
| once, | ||
| promisify, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should we use
??=?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find
??=more readable and concise than theifstatement, feel free to disagree and/or disregard.