* @param {function} customErrFn * @return {Promise<*>} * @inner
(customErrFn)
| 287 | * @inner |
| 288 | */ |
| 289 | catchWithoutStop(customErrFn) { |
| 290 | const fnDescription = customErrFn |
| 291 | ?.toString() |
| 292 | ?.replace(/\s{2,}/g, ' ') |
| 293 | .replace(/\n/g, ' ') |
| 294 | ?.slice(0, 50) |
| 295 | if (!promise) promise = Promise.resolve() |
| 296 | return (promise = promise.catch(err => { |
| 297 | if (ignoredErrs.includes(err)) return // already caught |
| 298 | |
| 299 | // Handle terminal errors - don't continue, re-throw immediately |
| 300 | if (err && (err.isTerminal || (err.message && (err.message.includes('ERR_ABORTED') || err.message.includes('frame was detached') || err.message.includes('Target page, context or browser has been closed'))))) { |
| 301 | output.log(`${currentQueue()} Terminal Error | ${err} | ${fnDescription || ''}...`) |
| 302 | throw err // Re-throw terminal errors immediately |
| 303 | } |
| 304 | |
| 305 | output.log(`${currentQueue()} Error (Non-Terminated) | ${err} | ${fnDescription || ''}...`) |
| 306 | if (!(err instanceof Error)) { |
| 307 | // strange things may happen |
| 308 | err = new Error(`[Wrapped Error] ${JSON.stringify(err)}`) // we should be prepared for them |
| 309 | } |
| 310 | if (customErrFn) { |
| 311 | try { |
| 312 | const result = customErrFn(err) |
| 313 | // If customErrFn returns a value (not throwing), treat it as handled |
| 314 | return result |
| 315 | } catch (thrownErr) { |
| 316 | // If customErrFn throws an error, propagate it up |
| 317 | throw thrownErr |
| 318 | } |
| 319 | } |
| 320 | })) |
| 321 | }, |
| 322 | |
| 323 | /** |
| 324 | * Adds a promise which throws an error into a chain |
nothing calls this directly
no test coverage detected