Hyperlinkv0.8.0-beta.28

Schema

Schema.catchDecodingWithContextfunctioneffect/Schema.ts:5320
<S extends Constraint, R = never>(
  f: (
    issue: SchemaIssue.Issue
  ) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>
): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>

Recovers from a decoding error with a handler that may require Effect services.

When to use

Use when you need decoding fallback logic to require services from the Effect context.

Details

The handler receives the Issue and returns an Effect that either succeeds with a fallback value or re-fails with a (possibly different) issue. The handler's services are added to the schema's decoding services.

Source effect/Schema.ts:53206 lines
export function catchDecodingWithContext<S extends Constraint, R = never>(
  f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>
) {
  return (self: S): middlewareDecoding<S, S["DecodingServices"] | R> =>
    middlewareDecoding<S, S["DecodingServices"] | R>(Effect.catchEager(f))(self)
}
Referenced by 1 symbols