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

Function handleKnownInternalErrors

lib/internal/webstreams/adapters.js:118–140  ·  view source on GitHub ↗

* @param {Error|null} cause * @returns {Error|null}

(cause)

Source from the content-addressed store, hash-verified

116 * @returns {Error|null}
117 */
118function handleKnownInternalErrors(cause) {
119 const causeCode = cause?.code;
120 switch (true) {
121 case causeCode === 'ERR_STREAM_PREMATURE_CLOSE': {
122 return new AbortError(undefined, { cause });
123 }
124 case ZLIB_FAILURES.has(causeCode):
125 // Brotli decoder error codes are formatted as 'ERR_' +
126 // BrotliDecoderErrorString(), where the latter returns strings like
127 // '_ERROR_FORMAT_...', '_ERROR_ALLOC_...', '_ERROR_UNREACHABLE', etc.
128 // The resulting JS error codes all start with 'ERR__ERROR_'.
129 // Falls through
130 case causeCode != null &&
131 StringPrototypeStartsWith(causeCode, 'ERR__ERROR_'): {
132 // eslint-disable-next-line no-restricted-syntax
133 const error = new TypeError(undefined, { cause });
134 setOwnProperty(error, 'code', causeCode);
135 return error;
136 }
137 default:
138 return cause;
139 }
140}
141
142const noop = () => {};
143

Calls 2

setOwnPropertyFunction · 0.85
hasMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…