(isAsync, req, res)
| 692 | } |
| 693 | |
| 694 | function buildAsyncConstraintCallback (isAsync, req, res) { |
| 695 | if (isAsync === false) return undefined |
| 696 | return function onAsyncConstraintError (err) { |
| 697 | if (err) { |
| 698 | if (options.frameworkErrors) { |
| 699 | const id = getGenReqId(routeEventContext.server, req) |
| 700 | const childLogger = createChildLogger(routeEventContext, options.logger, req, id) |
| 701 | |
| 702 | const request = new Request(id, null, req, null, childLogger, routeEventContext) |
| 703 | const reply = new Reply(res, request, childLogger) |
| 704 | |
| 705 | const resolvedDisableRequestLogging = typeof disableRequestLogging === 'function' ? disableRequestLogging(req) : disableRequestLogging |
| 706 | if (resolvedDisableRequestLogging === false) { |
| 707 | childLogger.info({ req: request }, 'incoming request') |
| 708 | } |
| 709 | |
| 710 | return options.frameworkErrors(new FST_ERR_ASYNC_CONSTRAINT(), request, reply) |
| 711 | } |
| 712 | const body = '{"error":"Internal Server Error","message":"Unexpected error from async constraint","statusCode":500}' |
| 713 | res.writeHead(500, { |
| 714 | 'Content-Type': 'application/json', |
| 715 | 'Content-Length': body.length |
| 716 | }) |
| 717 | res.end(body) |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | function setNotFoundHandler (opts, handler) { |
| 723 | throwIfAlreadyStarted('Cannot call "setNotFoundHandler"!') |
no test coverage detected