mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
lib: legitimize SuppressedError as primordial
Signed-off-by: LiviaMedeiros <livia@cirno.name> PR-URL: https://github.com/nodejs/node/pull/67551 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
1 parent
a5fd90f595
commit
4b810e2c5e
3 files changed
+4
-4
No files matched your search
@@ -23,7 +23,7 @@ const noRestrictedSyntax = [
|
||||
message: "`btoa` supports only latin-1 charset, use Buffer.from(str).toString('base64') instead",
|
||||
},
|
||||
{
|
||||
selector: 'NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError|AbortError|NodeAggregateError|QuicError|QuotaExceededError)$/])',
|
||||
selector: 'NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError|AbortError|NodeAggregateError|QuicError|QuotaExceededError|SuppressedError)$/])',
|
||||
message: "Use an error exported by 'internal/errors' instead.",
|
||||
},
|
||||
{
|
||||
@@ -507,6 +507,7 @@ export default [
|
||||
into: 'Safe',
|
||||
},
|
||||
{ name: 'String' },
|
||||
{ name: 'SuppressedError' },
|
||||
{ name: 'Symbol' },
|
||||
{ name: 'SyntaxError' },
|
||||
{ name: 'TypeError' },
|
||||
|
||||
@@ -19,6 +19,7 @@ const {
|
||||
PromisePrototypeThen,
|
||||
PromiseWithResolvers,
|
||||
SafeSet,
|
||||
SuppressedError,
|
||||
Symbol,
|
||||
SymbolAsyncDispose,
|
||||
SymbolAsyncIterator,
|
||||
@@ -1231,14 +1232,12 @@ function invokeOnerror(fn, error) {
|
||||
if (isPromise(result)) {
|
||||
PromisePrototypeThen(result, undefined, (err) => {
|
||||
process.nextTick(() => {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
throw new SuppressedError(err, error, err?.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
process.nextTick(() => {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
throw new SuppressedError(err, error, err?.message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ const {
|
||||
PromisePrototypeThen,
|
||||
SafePromiseAllReturnVoid,
|
||||
SafeSet,
|
||||
SuppressedError,
|
||||
Symbol,
|
||||
SymbolAsyncIterator,
|
||||
TypedArrayPrototypeGetBuffer,
|
||||
@@ -645,7 +646,6 @@ async function cleanupIterators(iterators, primaryError, pendingPulls) {
|
||||
// Both a primary error and a cleanup error occurred.
|
||||
// Wrap in SuppressedError so neither is lost:
|
||||
// .error = primaryError, .suppressed = cleanupError.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
throw new SuppressedError(primaryError, cleanupError);
|
||||
}
|
||||
// No primary error - the cleanup error is the only error.
|
||||
|
||||
Reference in new issue
Block a user