Repository: nodejs/node
File: lib/internal/util/inspect.js (JavaScript)

Code before:
    const s = ctx.stylize;
    const sp = 'special';
    if (ctx.getters && (ctx.getters === true ||
          (ctx.getters === 'get' && desc.set === undefined) ||
          (ctx.getters === 'set' && desc.set !== undefined))) {
      try {
        const tmp = FunctionPrototypeCall(desc.get, original);
        ctx.indentationLvl += 2;
        if (tmp === null) {
          str = `${s(`[${label}:`, sp)} ${s('null', 'null')}${s(']', sp)}`;
        } else if (typeof tmp === 'object') {
          str = `${s(`[${label}]`, sp)} ${formatValue(ctx, tmp, recurseTimes)}`;
        } else {
          const primitive = formatPrimitive(s, tmp, ctx);
          str = `${s(`[${label}:`, sp)} ${primitive}${s(']', sp)}`;
        }
        ctx.indentationLvl -= 2;
      } catch (err) {
        let messageSuffix;
        try {
          // Error message itself may be a getter
          messageSuffix = ` (${err.message})`;
        } catch {
          messageSuffix = '';
        }
        const message = `<Inspection threw${messageSuffix}>`;
        str = `${s(`[${label}:`, sp)} ${message}${s(']', sp)}`;
      }
    } else {
      str = ctx.stylize(`[${label}]`, sp);
    }
  } else if (desc.set !== undefined) {
    str = ctx.stylize('[Setter]', 'special');
  } else {
    str = ctx.stylize('undefined', 'undefined');
  }
  if (type === kArrayType) {
    return str;
  }
  if (typeof key === 'symbol') {
    const tmp = RegExpPrototypeSymbolReplace(
      strEscapeSequencesReplacer,
      SymbolPrototypeToString(key),
      escapeFn,
    );
    name = ctx.stylize(tmp, 'symbol');
  } else if (RegExpPrototypeExec(keyStrRegExp, key) !== null) {
    name = key === '__proto__' ? "['__proto__']" : ctx.stylize(key, 'name');
  } else {
    name = ctx.stylize(strEscape(key), 'string');
  }

Review comment (suggestion):
wdyt of doing this instead?
```suggestion
       let message = '<Inspection threw>';
       if (isErrorStackTraceLimitWritable()) {
         const stackTraceLimit = Error.stackTraceLimit;
         Error.stackTraceLimit = 0;
         try { message = `<Inspection threw (${inspect(err)})>`; }
         catch {}
         finally { Error.stackTraceLimit = stackTraceLimit; }
       } 
```

Code after:
    const s = ctx.stylize;
    const sp = 'special';
    if (ctx.getters && (ctx.getters === true ||
          (ctx.getters === 'get' && desc.set === undefined) ||
          (ctx.getters === 'set' && desc.set !== undefined))) {
      ctx.indentationLvl += 2;
      try {
        const tmp = FunctionPrototypeCall(desc.get, original);
        if (tmp === null) {
          str = `${s(`[${label}:`, sp)} ${s('null', 'null')}${s(']', sp)}`;
        } else if (typeof tmp === 'object') {
          str = `${s(`[${label}]`, sp)} ${formatValue(ctx, tmp, recurseTimes)}`;
        } else {
          const primitive = formatPrimitive(s, tmp, ctx);
          str = `${s(`[${label}:`, sp)} ${primitive}${s(']', sp)}`;
        }
      } catch (err) {
        const message = `<Inspection threw (${formatValue(ctx, err, recurseTimes)})>`;
        str = `${s(`[${label}:`, sp)} ${message}${s(']', sp)}`;
      }
      ctx.indentationLvl -= 2;
    } else {
      str = ctx.stylize(`[${label}]`, sp);
    }
  } else if (desc.set !== undefined) {
    str = ctx.stylize('[Setter]', 'special');
  } else {
    str = ctx.stylize('undefined', 'undefined');
  }
  if (type === kArrayType) {
    return str;
  }
  if (typeof key === 'symbol') {
    const tmp = RegExpPrototypeSymbolReplace(
      strEscapeSequencesReplacer,
      SymbolPrototypeToString(key),
      escapeFn,
    );
    name = ctx.stylize(tmp, 'symbol');
  } else if (RegExpPrototypeExec(keyStrRegExp, key) !== null) {
    name = key === '__proto__' ? "['__proto__']" : ctx.stylize(key, 'name');
  } else {
    name = ctx.stylize(strEscape(key), 'string');
  }

  if (desc.enumerable === false) {
    name = `[${name}]`;
  }
  return `${name}:${extra}${str}`;
}