* @param {Error|null} cause * @returns {Error|null}
(cause)
| 116 | * @returns {Error|null} |
| 117 | */ |
| 118 | function 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 | |
| 142 | const noop = () => {}; |
| 143 |
no test coverage detected
searching dependent graphs…