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

Function fixErrorStack

lib/utils/typescript.js:416–435  ·  view source on GitHub ↗
(error, fileMapping)

Source from the content-addressed store, hash-verified

414 * @returns {Error} - Error with fixed stack trace
415 */
416export function fixErrorStack(error, fileMapping) {
417 if (!error.stack || !fileMapping) return error
418
419 let stack = error.stack
420
421 // Create reverse mapping (temp.mjs -> original.ts)
422 const reverseMap = new Map()
423 for (const [tsFile, mjsFile] of fileMapping.entries()) {
424 reverseMap.set(mjsFile, tsFile)
425 }
426
427 // Replace all temp.mjs references with original .ts files
428 for (const [mjsFile, tsFile] of reverseMap.entries()) {
429 const mjsPattern = mjsFile.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
430 stack = stack.replace(new RegExp(mjsPattern, 'g'), tsFile)
431 }
432
433 error.stack = stack
434 return error
435}
436
437/**
438 * Clean up temporary transpiled files

Callers 7

requireHelperFromModuleFunction · 0.90
loadSupportObjectFunction · 0.90
loadConfigFileFunction · 0.90
resultMethod · 0.90
createMethod · 0.90
recordStepFunction · 0.90
runTests.jsFile · 0.85

Calls 1

entriesMethod · 0.80

Tested by

no test coverage detected