mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
lib: avoid mutating Error.stackTraceLimit when it is not writable
PR-URL: https://github.com/nodejs/node/pull/38215 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
1 parent
98c2067f13
commit
09c9e5dea4
13 files changed
+221
-31
No files matched your search
@@ -24,6 +24,7 @@ const {
|
||||
const {
|
||||
validateObject,
|
||||
} = require('internal/validators');
|
||||
const { isErrorStackTraceLimitWritable } = require('internal/errors');
|
||||
|
||||
let blue = '';
|
||||
let green = '';
|
||||
@@ -341,7 +342,7 @@ class AssertionError extends Error {
|
||||
} = options;
|
||||
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 0;
|
||||
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
||||
|
||||
if (message != null) {
|
||||
super(String(message));
|
||||
@@ -436,7 +437,7 @@ class AssertionError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
Error.stackTraceLimit = limit;
|
||||
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
||||
|
||||
this.generatedMessage = !message;
|
||||
ObjectDefineProperty(this, 'name', {
|
||||
|
||||
Reference in new issue
Block a user