MCPcopy
hub / github.com/codeceptjs/CodeceptJS / tryBlock

Function tryBlock

lib/effects.js:215–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213 }
214
215 const tryBlock = async () => {
216 tries++
217 recorder.session.start(`${sessionName} ${tries}`)
218 try {
219 await callback(tries)
220 } catch (err) {
221 recorder.throw(err)
222 }
223
224 // Call done if no errors
225 recorder.add(() => {
226 recorder.session.restore(`${sessionName} ${tries}`)
227 done(null)
228 })
229
230 // Catch errors and retry
231 recorder.session.catch(err => {
232 recorder.session.restore(`${sessionName} ${tries}`)
233 if (tries < maxTries) {
234 output.debug(`Error ${err}... Retrying`)
235 recorder.add(`${sessionName} ${tries}`, () => setTimeout(tryBlock, pollInterval))
236 } else {
237 // if maxTries reached
238 handleRetryException(err)
239 }
240 })
241 }
242
243 recorder.add(sessionName, tryBlock).catch(err => {
244 console.error('An error occurred:', err)

Callers

nothing calls this directly

Calls 6

callbackFunction · 0.85
doneFunction · 0.85
handleRetryExceptionFunction · 0.85
debugMethod · 0.80
startMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected