MCPcopy Create free account
hub / github.com/effect-app/libs / handleCause

Function handleCause

repos/effect/packages/effect/src/unstable/http/HttpEffect.ts:44–66  ·  view source on GitHub ↗
(cause: Cause.Cause<E | EH | HttpServerError>)

Source from the content-addressed store, hash-verified

42 middleware?: HttpMiddleware | undefined
43): Effect.Effect<void, never, Exclude<R | RH | HttpServerRequest, Scope.Scope>> => {
44 const handleCause = (cause: Cause.Cause<E | EH | HttpServerError>) =>
45 Effect.flatMapEager(causeResponse(cause), ([response, cause]) => {
46 const fiber = Fiber.getCurrent()!
47 reportCauseUnsafe(fiber, cause)
48 const request = Context.getUnsafe(fiber.context, HttpServerRequest)
49 const handler = preResponseHandler.requestPreResponseHandlers.get(request.source)
50 const cont = cause.reasons.length === 0 ? Effect.succeed(response) : Effect.failCause(cause)
51 if (handler === undefined) {
52 ;(request as any)[handledSymbol] = true
53 return Effect.flatMapEager(
54 handleResponse(request, response),
55 () => cont
56 )
57 }
58
59 return Effect.flatMapEager(
60 Effect.flatMapEager(handler(request, response), (response) => {
61 ;(request as any)[handledSymbol] = true
62 return handleResponse(request, response)
63 }),
64 () => cont
65 )
66 })
67
68 const responded = Effect.matchCauseEffect(self, {
69 onSuccess: (response) => {

Callers

nothing calls this directly

Calls 6

causeResponseFunction · 0.90
getUnsafeMethod · 0.80
handlerFunction · 0.70
getMethod · 0.65
handleResponseFunction · 0.50
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…