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

Function findError

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

Source from the content-addressed store, hash-verified

178
179/** @internal */
180export const findError = <E>(self: Cause.Cause<E>): Result.Result<E, Cause.Cause<never>> => {
181 for (let i = 0; i < self.reasons.length; i++) {
182 const reason = self.reasons[i]
183 if (reason._tag === "Fail") {
184 return Result.succeed(reason.error)
185 }
186 }
187 return Result.fail(self as Cause.Cause<never>)
188}
189
190/** @internal */
191export const findErrorOption = Filter.toOption(findError)

Callers 1

findRecoverableErrorFunction · 0.85

Calls 2

failMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected