MCPcopy Create free account
hub / github.com/fastify/fastify / setErrorHeaders

Function setErrorHeaders

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

Source from the content-addressed store, hash-verified

132}
133
134function setErrorHeaders (error, reply) {
135 const res = reply.raw
136 let statusCode = res.statusCode
137 statusCode = (statusCode >= 400) ? statusCode : 500
138 // treat undefined and null as same
139 if (error != null) {
140 if (error.headers !== undefined) {
141 reply.headers(error.headers)
142 }
143 if (error.status >= 400) {
144 statusCode = error.status
145 } else if (error.statusCode >= 400) {
146 statusCode = error.statusCode
147 }
148 }
149 res.statusCode = statusCode
150}
151
152module.exports = {
153 buildErrorHandler,

Callers 1

defaultErrorHandlerFunction · 0.85

Calls 1

headersMethod · 0.80

Tested by

no test coverage detected