| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b1e739d commit 7e70233
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,10 @@ function TryGetAllProperties(object, target = object) { | |||
| 36 | 36 | Assign(all, TryGetAllProperties(GetPrototypeOf(object), target)); | |
| 37 | 37 | const keys = GetOwnPropertyNames(object); | |
| 38 | 38 | ForEach(keys, (key) => { | |
| 39 | - const descriptor = GetOwnPropertyDescriptor(object, key); | ||
| 39 | + let descriptor; | ||
| 40 | + try { | ||
| 41 | + descriptor = GetOwnPropertyDescriptor(object, key); | ||
| 42 | + } catch { return; } | ||
| 40 | 43 | const getter = descriptor.get; | |
| 41 | 44 | if (getter && key !== '__proto__') { | |
| 42 | 45 | try { | |
@@ -89,7 +92,6 @@ function serializeError(error) { | |||
| 89 | 92 | for (var i = 0; i < constructors.length; i++) { | |
| 90 | 93 | const name = GetName(constructors[i]); | |
| 91 | 94 | if (errorConstructorNames.has(name)) { | |
| 92 | - try { error.stack; } catch {} | ||
| 93 | 95 | const serialized = serialize({ | |
| 94 | 96 | constructor: name, | |
| 95 | 97 | properties: TryGetAllProperties(error) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { Worker } = require('worker_threads'); | ||
| 5 | + | ||
| 6 | + const w = new Worker( | ||
| 7 | + `const fn = (err) => { | ||
| 8 | + if (err.message === 'fhqwhgads') | ||
| 9 | + throw new Error('come on'); | ||
| 10 | + return 'This is my custom stack trace!'; | ||
| 11 | + }; | ||
| 12 | + Error.prepareStackTrace = fn; | ||
| 13 | + throw new Error('fhqwhgads'); | ||
| 14 | + `, | ||
| 15 | + { eval: true } | ||
| 16 | + ); | ||
| 17 | + w.on('message', common.mustNotCall()); | ||
| 18 | + w.on('error', common.mustCall((err) => { | ||
| 19 | + assert.strictEqual(err.stack, undefined); | ||
| 20 | + assert.strictEqual(err.message, 'fhqwhgads'); | ||
| 21 | + assert.strictEqual(err.name, 'Error'); | ||
| 22 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments