MCPcopy Index your code
hub / github.com/nodejs/node / afterInspector

Function afterInspector

lib/internal/errors.js:913–947  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

911 return error.stack;
912 },
913 afterInspector(error) {
914 const originalStack = error.stack;
915 let useColors = true;
916 // Some consoles do not convert ANSI escape sequences to colors,
917 // rather display them directly to the stdout. On those consoles,
918 // libuv emulates colors by intercepting stdout stream and calling
919 // corresponding Windows API functions for setting console colors.
920 // However, fatal error are handled differently and we cannot easily
921 // highlight them. On Windows, detecting whether a console supports
922 // ANSI escape sequences is not reliable.
923 if (isWindows) {
924 const info = internalBinding('os').getOSInformation();
925 const ver = ArrayPrototypeMap(StringPrototypeSplit(info[2], '.', 3),
926 Number);
927 if (ver[0] !== 10 || ver[2] < 14393) {
928 useColors = false;
929 }
930 }
931 const {
932 inspect,
933 inspectDefaultOptions: {
934 colors: defaultColors,
935 },
936 } = lazyInternalUtilInspect();
937 const colors = useColors && (lazyUtilColors().shouldColorize(process.stderr) || defaultColors);
938 try {
939 return inspect(error, {
940 colors,
941 customInspect: false,
942 depth: MathMax(inspect.defaultOptions.depth, 5),
943 });
944 } catch {
945 return originalStack;
946 }
947 },
948};
949
950const {

Callers

nothing calls this directly

Calls 4

lazyInternalUtilInspectFunction · 0.85
getOSInformationMethod · 0.80
lazyUtilColorsFunction · 0.70
inspectFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…