SchemaError.ts
SchemaError.ts overview
Section titled “SchemaError.ts overview”Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”errors
Section titled “errors”SchemaError (class)
Section titled “SchemaError (class)”Error thrown (or returned as the error channel value) when schema decoding or encoding fails.
Details
The issue field contains a structured Issue tree describing
every validation failure, including the path to the problematic value,
expected types, and actual values received. message renders the issue tree
as a human-readable string.
Use isSchemaError to narrow an unknown value to SchemaError.
Example (Catching a SchemaError)
import { Schema } from "effect"
try { Schema.decodeUnknownSync(Schema.Number)("not a number")} catch (err) { if (Schema.isSchemaError(err)) { console.log(err.message) // Expected number, actual "not a number" }}Signature
declare class SchemaError { constructor(issue: Issue)}Since v4.0.0
toString (method)
Section titled “toString (method)”Signature
declare const toString: () => string[TypeId] (property)
Section titled “[TypeId] (property)”Signature
readonly [TypeId]: "~effect/SchemaError/SchemaError"guards
Section titled “guards”isSchemaError
Section titled “isSchemaError”Returns true if u is a SchemaError.
Signature
declare const isSchemaError: (u: unknown) => u is SchemaErrorSince v4.0.0