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