mirror of https://github.com/nodejs/node.git
errors: support possible deletion of globalThis.Error
Do not crash trying to access prepareStackTrace on `undefined`. PR-URL: https://github.com/nodejs/node/pull/35499 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Shingo Inoue <leko.noor@gmail.com>pull/35541/head
parent
27c77b9350
commit
46526d6cad
|
@ -81,7 +81,7 @@ const maybeOverridePrepareStackTrace = (globalThis, error, trace) => {
|
|||
// https://crbug.com/v8/7848
|
||||
// `globalThis` is the global that contains the constructor which
|
||||
// created `error`.
|
||||
if (typeof globalThis.Error.prepareStackTrace === 'function') {
|
||||
if (typeof globalThis.Error?.prepareStackTrace === 'function') {
|
||||
return globalThis.Error.prepareStackTrace(error, trace);
|
||||
}
|
||||
// We still have legacy usage that depends on the main context's `Error`
|
||||
|
|
Loading…
Reference in New Issue