Package: effect
Module: Schema
Recovers from a decoding error by providing a fallback value.
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.
Example (Returning a default on decode failure)
import { Effect, Option, Schema } from "effect"
const schema = Schema.Number.pipe(
Schema.catchDecoding((_issue) => Effect.succeed(Option.some(0)))
)
See
catchDecodingWithContext to add service requirements to the handlerSignature
declare const catchDecoding: <S extends Constraint>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue>) => (self: S) => middlewareDecoding<S, S["DecodingServices"]>
Since v4.0.0