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

Function layer

packages/effect/src/ErrorReporter.ts:234–258  ·  view source on GitHub ↗
(
  reporters: Reporters,
  options?: { readonly mergeWithExisting?: boolean | undefined } | undefined
)

Source from the content-addressed store, hash-verified

232 * @since 4.0.0
233 */
234export const layer = <
235 const Reporters extends ReadonlyArray<ErrorReporter | Effect.Effect<ErrorReporter, any, any>>
236>(
237 reporters: Reporters,
238 options?: { readonly mergeWithExisting?: boolean | undefined } | undefined
239): Layer.Layer<
240 never,
241 Reporters extends readonly [] ? never : Effect.Error<Reporters[number]>,
242 Exclude<
243 Reporters extends readonly [] ? never : Effect.Services<Reporters[number]>,
244 Scope.Scope
245 >
246> =>
247 Layer.effect(
248 CurrentErrorReporters,
249 Effect.withFiber(Effect.fnUntraced(function*(fiber) {
250 const currentReporters = new Set(
251 options?.mergeWithExisting === true ? fiber.getRef(references.CurrentErrorReporters) : []
252 )
253 for (const reporter of reporters) {
254 currentReporters.add(Effect.isEffect(reporter) ? yield* reporter : reporter)
255 }
256 return currentReporters
257 }))
258 )
259
260/**
261 * Runs all registered error reporters on the current fiber for a `Cause`.

Callers

nothing calls this directly

Calls 2

getRefMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected