MCPcopy Create free account
hub / github.com/Effect-TS/effect / handleCause

Function handleCause

packages/platform-node/src/internal/httpServer.ts:496–516  ·  view source on GitHub ↗
(
  nodeResponse: Http.ServerResponse,
  original: ServerResponse.HttpServerResponse
)

Source from the content-addressed store, hash-verified

494 })
495
496const handleCause = (
497 nodeResponse: Http.ServerResponse,
498 original: ServerResponse.HttpServerResponse
499) =>
500<E>(originalCause: Cause.Cause<E>) =>
501 Error.causeResponse(originalCause).pipe(
502 Effect.flatMap(([response, cause]) => {
503 const headersSent = nodeResponse.headersSent
504 if (!headersSent) {
505 nodeResponse.writeHead(response.status)
506 }
507 if (!nodeResponse.writableEnded) {
508 nodeResponse.end()
509 }
510 return Effect.failCause(
511 headersSent
512 ? Cause.sequential(originalCause, Cause.die(original))
513 : cause
514 )
515 })
516 )
517
518/** @internal */
519export const toIncomingMessage = (self: ServerRequest.HttpServerRequest): Http.IncomingMessage =>

Callers 1

handleResponseFunction · 0.85

Calls 4

failCauseMethod · 0.80
pipeMethod · 0.65
endMethod · 0.65
dieMethod · 0.65

Tested by

no test coverage detected