Hyperlinkv0.8.0-beta.28

Stream

Stream.ignoreCauseconsteffect/Stream.ts:6093
<
  Arg extends
    | Stream<any, any, any>
    | { readonly log?: boolean | Severity | undefined }
    | undefined
>(
  streamOrOptions: Arg,
  options?: { readonly log?: boolean | Severity | undefined } | undefined
): [Arg] extends [Stream<infer A, infer _E, infer R>]
  ? Stream<A, never, R>
  : <A, E, R>(self: Stream<A, E, R>) => Stream<A, never, R>

Ignores the stream's failure cause, including defects, and ends the stream.

When to use

Use when you need to silently suppress a stream's entire failure cause, including both typed errors and defects, rather than propagate it downstream.

Example (Ignoring stream failure causes)

import { Effect, Stream } from "effect"

Effect.runPromise(Effect.gen(function*() {
  const values = yield* Stream.make(1, 2).pipe(
    Stream.concat(Stream.die("boom")),
    Stream.ignoreCause({ log: false }),
    Stream.runCollect
  )
  yield* Effect.sync(() => console.log(values))
}))

// [ 1, 2 ]
error handlingignore
Source effect/Stream.ts:609317 lines
export const ignoreCause: <
  Arg extends Stream<any, any, any> | {
    readonly log?: boolean | Severity | undefined
  } | undefined
>(
  streamOrOptions: Arg,
  options?: {
    readonly log?: boolean | Severity | undefined
  } | undefined
) => [Arg] extends [Stream<infer A, infer _E, infer R>] ? Stream<A, never, R>
  : <A, E, R>(self: Stream<A, E, R>) => Stream<A, never, R> = dual(
    (args) => isStream(args[0]),
    <A, E, R>(
      self: Stream<A, E, R>,
      options?: { readonly log?: boolean | Severity | undefined } | undefined
    ): Stream<A, never, R> => fromChannel(Channel.ignoreCause(self.channel, options))
  )