MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / catchWithoutStop

Function catchWithoutStop

lib/recorder.js:289–321  ·  view source on GitHub ↗

* @param {function} customErrFn * @return {Promise<*>} * @inner

(customErrFn)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

currentQueueFunction · 0.85
includesMethod · 0.80
logMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected