MCPcopy Create free account
hub / github.com/nodejs/undici / appendFetchStackTrace

Function appendFetchStackTrace

index.js:132–154  ·  view source on GitHub ↗
(err, filename)

Source from the content-addressed store, hash-verified

130const currentFilename = typeof __filename !== 'undefined' ? __filename : undefined
131
132function appendFetchStackTrace (err, filename) {
133 if (!err || typeof err !== 'object') {
134 return
135 }
136
137 const stack = typeof err.stack === 'string' ? err.stack : ''
138 const normalizedFilename = filename.replace(/\\/g, '/')
139
140 if (stack && (stack.includes(filename) || stack.includes(normalizedFilename))) {
141 return
142 }
143
144 const capture = {}
145 Error.captureStackTrace(capture, appendFetchStackTrace)
146
147 if (!capture.stack) {
148 return
149 }
150
151 const captureLines = capture.stack.split('\n').slice(1).join('\n')
152
153 err.stack = stack ? `${stack}\n${captureLines}` : capture.stack
154}
155
156module.exports.fetch = function fetch (init, options = undefined) {
157 return fetchImpl(init, options).catch(err => {

Callers 1

index.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected