Hyperlinkv0.8.0-beta.28

SchemaIssue

SchemaIssue.isIssuefunctioneffect/SchemaIssue.ts:55
(u: unknown): u is Issue

Returns true if the given value is an Issue.

When to use

Use when you need to narrow an unknown value to Issue in error-handling code, such as distinguishing an Issue from other error types in a catch-all handler.

Details

  • Checks for the internal TypeId brand on the value.

Example (Type-guarding an unknown error)

import { SchemaIssue } from "effect"

const issue = new SchemaIssue.MissingKey(undefined)
console.log(SchemaIssue.isIssue(issue))
// true
console.log(SchemaIssue.isIssue("not an issue"))
// false
guardsIssue
export function isIssue(u: unknown): u is Issue {
  return hasProperty(u, TypeId)
}