MCPcopy
hub / github.com/nodejs/undici / onResponseEnd

Method onResponseEnd

lib/interceptor/response-error.js:54–82  ·  view source on GitHub ↗
(controller, trailers)

Source from the content-addressed store, hash-verified

52 }
53
54 onResponseEnd (controller, trailers) {
55 if (this.#statusCode >= 400) {
56 this.#body += this.#decoder?.decode(undefined, { stream: false }) ?? ''
57
58 if (this.#checkContentType('application/json')) {
59 try {
60 this.#body = JSON.parse(this.#body)
61 } catch {
62 // Do nothing...
63 }
64 }
65
66 let err
67 const stackTraceLimit = Error.stackTraceLimit
68 Error.stackTraceLimit = 0
69 try {
70 err = new ResponseError('Response Error', this.#statusCode, {
71 body: this.#body,
72 headers: this.#headers
73 })
74 } finally {
75 Error.stackTraceLimit = stackTraceLimit
76 }
77
78 super.onResponseError(controller, err)
79 } else {
80 super.onResponseEnd(controller, trailers)
81 }
82 }
83
84 onResponseError (controller, err) {
85 super.onResponseError(controller, err)

Callers

nothing calls this directly

Calls 3

#checkContentTypeMethod · 0.95
onResponseErrorMethod · 0.65
onResponseEndMethod · 0.65

Tested by

no test coverage detected