MCPcopy
hub / github.com/fastify/fastify / setErrorHeaders

Function setErrorHeaders

lib/error-handler.js:153–169  ·  view source on GitHub ↗
(error, reply)

Source from the content-addressed store, hash-verified

151}
152
153function setErrorHeaders (error, reply) {
154 const res = reply.raw
155 let statusCode = res.statusCode
156 statusCode = (statusCode >= 400) ? statusCode : 500
157 // treat undefined and null as same
158 if (error != null) {
159 if (error.headers !== undefined) {
160 reply.headers(error.headers)
161 }
162 if (error.status >= 400) {
163 statusCode = error.status
164 } else if (error.statusCode >= 400) {
165 statusCode = error.statusCode
166 }
167 }
168 res.statusCode = statusCode
169}
170
171module.exports = {
172 buildErrorHandler,

Callers 1

defaultErrorHandlerFunction · 0.85

Calls 1

headersMethod · 0.80

Tested by

no test coverage detected