effect-io-ai

Package: effect
Module: Schema

Schema.isSchemaError

Returns true if u is a SchemaError.

Example (Narrowing Schema errors in a catch block)

import { Schema } from "effect"

try {
  Schema.decodeUnknownSync(Schema.Number)("oops")
} catch (err) {
  if (Schema.isSchemaError(err)) {
    console.log(err._tag) // "SchemaError"
  }
}

Signature

declare const isSchemaError: (u: unknown) => u is SchemaError

Source

Since v4.0.0