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

Function findError

packages/effect/src/internal/effect.ts:157–165  ·  view source on GitHub ↗
(self: Cause.Cause<E>)

Source from the content-addressed store, hash-verified

155
156/** @internal */
157export const findError = <E>(self: Cause.Cause<E>): Result.Result<E, Cause.Cause<never>> => {
158 for (let i = 0; i < self.reasons.length; i++) {
159 const reason = self.reasons[i]
160 if (reason._tag === "Fail") {
161 return Result.succeed(reason.error)
162 }
163 }
164 return Result.fail(self as Cause.Cause<never>)
165}
166
167/** @internal */
168export const findErrorOption = Filter.toOption(findError)

Callers 1

effect.tsFile · 0.85

Calls 2

succeedMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected