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

Function setErrorHandler

fastify.js:762–778  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

760
761 // wrapper that we expose to the user for configure the custom error handler
762 function setErrorHandler (func) {
763 throwIfAlreadyStarted('Cannot call "setErrorHandler"!')
764
765 if (typeof func !== 'function') {
766 throw new FST_ERR_ERROR_HANDLER_NOT_FN()
767 }
768
769 if (!options.allowErrorHandlerOverride && this[kErrorHandlerAlreadySet]) {
770 throw new FST_ERR_ERROR_HANDLER_ALREADY_SET()
771 } else if (this[kErrorHandlerAlreadySet]) {
772 FSTWRN004()
773 }
774
775 this[kErrorHandlerAlreadySet] = true
776 this[kErrorHandler] = buildErrorHandler(this[kErrorHandler], func.bind(this))
777 return this
778 }
779
780 function setChildLoggerFactory (factory) {
781 throwIfAlreadyStarted('Cannot call "setChildLoggerFactory"!')

Callers

nothing calls this directly

Calls 2

throwIfAlreadyStartedFunction · 0.85
buildErrorHandlerFunction · 0.85

Tested by

no test coverage detected