Skip to content

Error Formatters

When working with Effect Schema, errors encountered during decoding or encoding operations can be formatted using two built-in methods: TreeFormatter and ArrayFormatter. These formatters help structure and present errors in a readable and actionable manner.

The TreeFormatter is the default method for formatting errors. It organizes errors in a tree structure, providing a clear hierarchy of issues.

Example (Decoding with Missing Properties)

1
import {
import Either
Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>(fields: { name: typeof Schema.String; age: typeof Schema.Number; }): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
})
7
8
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
=
import Schema
Schema
.
const decodeUnknownEither: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
decodeUnknownEither
(
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
)
9
10
const
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
=
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
({})
11
if (
import Either
Either
.
const isLeft: <{ readonly name: string; readonly age: number; }, ParseResult.ParseError>(self: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>) => self is Either.Left<...>

Determine if a `Either` is a `Left`.

isLeft
(
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
)) {
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
("Decoding failed:")
13
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
(
import ParseResult
ParseResult
.
const TreeFormatter: ParseResult.ParseResultFormatter<string>
TreeFormatter
.
(property) ParseResultFormatter<string>.formatErrorSync: (error: ParseResult.ParseError) => string
formatErrorSync
(
const result: Either.Left<ParseResult.ParseError, { readonly name: string; readonly age: number; }>
result
.
(property) Left<ParseError, { readonly name: string; readonly age: number; }>.left: ParseResult.ParseError
left
))
14
}
15
/*
16
Decoding failed:
17
{ readonly name: string; readonly age: number }
18
└─ ["name"]
19
└─ is missing
20
*/

In this example:

  • { readonly name: string; readonly age: number } describes the schema’s expected structure.
  • ["name"] identifies the specific field causing the error.
  • is missing explains the issue for the "name" field.

You can make the error output more concise and meaningful by annotating the schema with annotations like identifier, title, or description. These annotations replace the default TypeScript-like representation in the error messages.

Example (Using title Annotation for Clarity)

Adding a title annotation replaces the schema structure in the error message with the more human-readable “Person” making it easier to understand.

1
import {
import Either
Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>(fields: { name: typeof Schema.String; age: typeof Schema.Number; }): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
}).
(method) Struct<{ name: typeof String$; age: typeof Number$; }>.annotations(annotations: Schema.Annotations.Schema<{ readonly name: string; readonly age: number; }, readonly []>): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
(property) Annotations.Doc<{ readonly name: string; readonly age: number; }>.title?: string
title
: "Person" }) // Add a title annotation
7
8
const
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
=
import Schema
Schema
.
const decodeUnknownEither: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
decodeUnknownEither
(
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
)({})
9
if (
import Either
Either
.
const isLeft: <{ readonly name: string; readonly age: number; }, ParseResult.ParseError>(self: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>) => self is Either.Left<...>

Determine if a `Either` is a `Left`.

isLeft
(
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
)) {
10
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
(
import ParseResult
ParseResult
.
const TreeFormatter: ParseResult.ParseResultFormatter<string>
TreeFormatter
.
(property) ParseResultFormatter<string>.formatErrorSync: (error: ParseResult.ParseError) => string
formatErrorSync
(
const result: Either.Left<ParseResult.ParseError, { readonly name: string; readonly age: number; }>
result
.
(property) Left<ParseError, { readonly name: string; readonly age: number; }>.left: ParseResult.ParseError
left
))
11
}
12
/*
13
Person
14
└─ ["name"]
15
└─ is missing
16
*/

By default, decoding functions like Schema.decodeUnknownEither report only the first error. To list all errors, use the { errors: "all" } option.

Example (Listing All Errors)

1
import {
import Either
Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>(fields: { name: typeof Schema.String; age: typeof Schema.Number; }): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
})
7
8
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
=
import Schema
Schema
.
const decodeUnknownEither: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
decodeUnknownEither
(
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
, {
(property) ParseOptions.errors?: "first" | "all" | undefined

The `errors` option allows you to receive all parsing errors when attempting to parse a value using a schema. By default only the first error is returned, but by setting the `errors` option to `"all"`, you can receive all errors that occurred during the parsing process. This can be useful for debugging or for providing more comprehensive error messages to the user. default: "first"

errors
: "all" })
9
10
const
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
=
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
({})
11
if (
import Either
Either
.
const isLeft: <{ readonly name: string; readonly age: number; }, ParseResult.ParseError>(self: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>) => self is Either.Left<...>

Determine if a `Either` is a `Left`.

isLeft
(
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
)) {
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
("Decoding failed:")
13
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
(
import ParseResult
ParseResult
.
const TreeFormatter: ParseResult.ParseResultFormatter<string>
TreeFormatter
.
(property) ParseResultFormatter<string>.formatErrorSync: (error: ParseResult.ParseError) => string
formatErrorSync
(
const result: Either.Left<ParseResult.ParseError, { readonly name: string; readonly age: number; }>
result
.
(property) Left<ParseError, { readonly name: string; readonly age: number; }>.left: ParseResult.ParseError
left
))
14
}
15
/*
16
Decoding failed:
17
{ readonly name: string; readonly age: number }
18
├─ ["name"]
19
│ └─ is missing
20
└─ ["age"]
21
└─ is missing
22
*/

The parseIssueTitle annotation allows you to add dynamic context to error messages by generating titles based on the value being validated. For instance, it can include an ID from the validated object, making it easier to identify specific issues in complex or nested data structures.

Annotation Type

1
export type ParseIssueTitleAnnotation = (
2
issue: ParseIssue
3
) => string | undefined

Return Value:

  • If the function returns a string, the TreeFormatter uses it as the title unless a message annotation is present (which takes precedence).
  • If the function returns undefined, the TreeFormatter determines the title based on the following priority:
    1. identifier annotation
    2. title annotation
    3. description annotation
    4. Default TypeScript-like schema representation

Example (Dynamic Titles Using parseIssueTitle)

1
import type {
import ParseResult
ParseResult
} from "effect"
2
import {
import Schema
Schema
} from "effect"
3
4
// Function to generate titles for OrderItem issues
5
const
const getOrderItemId: ({ actual }: ParseResult.ParseIssue) => string | undefined
getOrderItemId
= ({
(parameter) actual: unknown
actual
}:
import ParseResult
ParseResult
.
type ParseIssue = ParseResult.Type | ParseResult.Missing | ParseResult.Unexpected | ParseResult.Forbidden | ParseResult.Pointer | ParseResult.Refinement | ParseResult.Transformation | ParseResult.Composite

`ParseIssue` is a type that represents the different types of errors that can occur when decoding/encoding a value.

ParseIssue
) => {
6
if (
import Schema
Schema
.
(alias) is<{ readonly id: string; }, { readonly id: string; }, never>(schema: Schema.Schema<{ readonly id: string; }, { readonly id: string; }, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions | number) => u is { readonly id: string; } export is

By default the option `exact` is set to `true`.

is
(
import Schema
Schema
.
function Struct<{ id: typeof Schema.String; }>(fields: { id: typeof Schema.String; }): Schema.Struct<{ id: typeof Schema.String; }> (+1 overload) namespace Struct
Struct
({
(property) id: typeof Schema.String
id
:
import Schema
Schema
.
(alias) class String export String
String
}))(
(parameter) actual: unknown
actual
)) {
7
return `OrderItem with id: ${
(parameter) actual: { readonly id: string; }
actual
.
(property) id: string
id
}`
8
}
9
}
10
11
const
const OrderItem: Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>
OrderItem
=
import Schema
Schema
.
function Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>(fields: { id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }): Schema.Struct<...> (+1 overload) namespace Struct
Struct
({
12
(property) id: typeof Schema.String
id
:
import Schema
Schema
.
(alias) class String export String
String
,
13
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
14
(property) price: typeof Schema.Number
price
:
import Schema
Schema
.
(alias) class Number export Number
Number
15
}).
(method) Struct<{ id: typeof String$; name: typeof String$; price: typeof Number$; }>.annotations(annotations: Schema.Annotations.Schema<{ readonly id: string; readonly name: string; readonly price: number; }, readonly []>): Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
16
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.identifier?: string
identifier
: "OrderItem",
17
(property) Annotations.Schema<{ readonly id: string; readonly name: string; readonly price: number; }, readonly []>.parseIssueTitle?: ParseIssueTitleAnnotation
parseIssueTitle
:
const getOrderItemId: ({ actual }: ParseResult.ParseIssue) => string | undefined
getOrderItemId
18
})
19
20
// Function to generate titles for Order issues
21
const
const getOrderId: ({ actual }: ParseResult.ParseIssue) => string | undefined
getOrderId
= ({
(parameter) actual: unknown
actual
}:
import ParseResult
ParseResult
.
type ParseIssue = ParseResult.Type | ParseResult.Missing | ParseResult.Unexpected | ParseResult.Forbidden | ParseResult.Pointer | ParseResult.Refinement | ParseResult.Transformation | ParseResult.Composite

`ParseIssue` is a type that represents the different types of errors that can occur when decoding/encoding a value.

ParseIssue
) => {
22
if (
import Schema
Schema
.
(alias) is<{ readonly id: number; }, { readonly id: number; }, never>(schema: Schema.Schema<{ readonly id: number; }, { readonly id: number; }, never>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions | number) => u is { readonly id: number; } export is

By default the option `exact` is set to `true`.

is
(
import Schema
Schema
.
function Struct<{ id: typeof Schema.Number; }>(fields: { id: typeof Schema.Number; }): Schema.Struct<{ id: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
(property) id: typeof Schema.Number
id
:
import Schema
Schema
.
(alias) class Number export Number
Number
}))(
(parameter) actual: unknown
actual
)) {
23
return `Order with id: ${
(parameter) actual: { readonly id: number; }
actual
.
(property) id: number
id
}`
24
}
25
}
26
27
const
const Order: Schema.Struct<{ id: typeof Schema.Number; name: typeof Schema.String; items: Schema.Array$<Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>>; }>
Order
=
import Schema
Schema
.
function Struct<{ id: typeof Schema.Number; name: typeof Schema.String; items: Schema.Array$<Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>>; }>(fields: { ...; }): Schema.Struct<...> (+1 overload) namespace Struct
Struct
({
28
(property) id: typeof Schema.Number
id
:
import Schema
Schema
.
(alias) class Number export Number
Number
,
29
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
30
(property) items: Schema.Array$<Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>>
items
:
import Schema
Schema
.
(alias) Array<Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>>(value: Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>): Schema.Array$<...> export Array
Array
(
const OrderItem: Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>
OrderItem
)
31
}).
(method) Struct<{ id: typeof Number$; name: typeof String$; items: Array$<Struct<{ id: typeof String$; name: typeof String$; price: typeof Number$; }>>; }>.annotations(annotations: Schema.Annotations.Schema<{ readonly id: number; readonly name: string; readonly items: readonly { readonly id: string; readonly name: string; readonly price: number; }[]; }, readonly []>): Schema.Struct<...>

Merges a set of new annotations with existing ones, potentially overwriting any duplicates.

annotations
({
32
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.identifier?: string
identifier
: "Order",
33
(property) Annotations.Schema<A, TypeParameters extends ReadonlyArray<any> = readonly []>.parseIssueTitle?: ParseIssueTitleAnnotation
parseIssueTitle
:
const getOrderId: ({ actual }: ParseResult.ParseIssue) => string | undefined
getOrderId
34
})
35
36
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => { readonly id: number; readonly name: string; readonly items: readonly { readonly id: string; readonly name: string; readonly price: number; }[]; }
decode
=
import Schema
Schema
.
(alias) decodeUnknownSync<{ readonly id: number; readonly name: string; readonly items: readonly { readonly id: string; readonly name: string; readonly price: number; }[]; }, { readonly id: number; readonly name: string; readonly items: readonly { ...; }[]; }>(schema: Schema.Schema<...>, options?: ParseOptions): (u: unknown, overrideOptions?: ParseOptions) => { ...; } export decodeUnknownSync
decodeUnknownSync
(
const Order: Schema.Struct<{ id: typeof Schema.Number; name: typeof Schema.String; items: Schema.Array$<Schema.Struct<{ id: typeof Schema.String; name: typeof Schema.String; price: typeof Schema.Number; }>>; }>
Order
, {
(property) ParseOptions.errors?: "first" | "all" | undefined

The `errors` option allows you to receive all parsing errors when attempting to parse a value using a schema. By default only the first error is returned, but by setting the `errors` option to `"all"`, you can receive all errors that occurred during the parsing process. This can be useful for debugging or for providing more comprehensive error messages to the user. default: "first"

errors
: "all" })
37
38
// Case 1: No id available, uses the `identifier` annotation
39
const decode: (u: unknown, overrideOptions?: ParseOptions) => { readonly id: number; readonly name: string; readonly items: readonly { readonly id: string; readonly name: string; readonly price: number; }[]; }
decode
({})
40
/*
41
throws
42
ParseError: Order
43
├─ ["id"]
44
│ └─ is missing
45
├─ ["name"]
46
│ └─ is missing
47
└─ ["items"]
48
└─ is missing
49
*/
50
51
// Case 2: ID present, uses the dynamic `parseIssueTitle` annotation
52
const decode: (u: unknown, overrideOptions?: ParseOptions) => { readonly id: number; readonly name: string; readonly items: readonly { readonly id: string; readonly name: string; readonly price: number; }[]; }
decode
({
(property) id: number
id
: 1 })
53
/*
54
throws
55
ParseError: Order with id: 1
56
├─ ["name"]
57
│ └─ is missing
58
└─ ["items"]
59
└─ is missing
60
*/
61
62
// Case 3: Nested issues with IDs for both Order and OrderItem
63
const decode: (u: unknown, overrideOptions?: ParseOptions) => { readonly id: number; readonly name: string; readonly items: readonly { readonly id: string; readonly name: string; readonly price: number; }[]; }
decode
({
(property) id: number
id
: 1,
(property) items: { id: string; price: string; }[]
items
: [{
(property) id: string
id
: "22b",
(property) price: string
price
: "100" }] })
64
/*
65
throws
66
ParseError: Order with id: 1
67
├─ ["name"]
68
│ └─ is missing
69
└─ ["items"]
70
└─ ReadonlyArray<OrderItem>
71
└─ [0]
72
└─ OrderItem with id: 22b
73
├─ ["name"]
74
│ └─ is missing
75
└─ ["price"]
76
└─ Expected a number, actual "100"
77
*/

The ArrayFormatter provides a structured, array-based approach to formatting errors. It represents each error as an object, making it easier to analyze and address multiple issues during data decoding or encoding. Each error object includes properties like _tag, path, and message for clarity.

Example (Single Error in Array Format)

1
import {
import Either
Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>(fields: { name: typeof Schema.String; age: typeof Schema.Number; }): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
})
7
8
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
=
import Schema
Schema
.
const decodeUnknownEither: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
decodeUnknownEither
(
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
)
9
10
const
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
=
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
({})
11
if (
import Either
Either
.
const isLeft: <{ readonly name: string; readonly age: number; }, ParseResult.ParseError>(self: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>) => self is Either.Left<...>

Determine if a `Either` is a `Left`.

isLeft
(
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
)) {
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
("Decoding failed:")
13
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
(
import ParseResult
ParseResult
.
const ArrayFormatter: ParseResult.ParseResultFormatter<ParseResult.ArrayFormatterIssue[]>
ArrayFormatter
.
(property) ParseResultFormatter<ArrayFormatterIssue[]>.formatErrorSync: (error: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]
formatErrorSync
(
const result: Either.Left<ParseResult.ParseError, { readonly name: string; readonly age: number; }>
result
.
(property) Left<ParseError, { readonly name: string; readonly age: number; }>.left: ParseResult.ParseError
left
))
14
}
15
/*
16
Decoding failed:
17
[ { _tag: 'Missing', path: [ 'name' ], message: 'is missing' } ]
18
*/

In this example:

  • _tag: Indicates the type of error (Missing).
  • path: Specifies the location of the error in the data (['name']).
  • message: Describes the issue ('is missing').

By default, decoding functions like Schema.decodeUnknownEither report only the first error. To list all errors, use the { errors: "all" } option.

Example (Listing All Errors)

1
import {
import Either
Either
,
import Schema
Schema
,
import ParseResult
ParseResult
} from "effect"
2
3
const
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
=
import Schema
Schema
.
function Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>(fields: { name: typeof Schema.String; age: typeof Schema.Number; }): Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }> (+1 overload) namespace Struct
Struct
({
4
(property) name: typeof Schema.String
name
:
import Schema
Schema
.
(alias) class String export String
String
,
5
(property) age: typeof Schema.Number
age
:
import Schema
Schema
.
(alias) class Number export Number
Number
6
})
7
8
const
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
=
import Schema
Schema
.
const decodeUnknownEither: <{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }>(schema: Schema.Schema<{ readonly name: string; readonly age: number; }, { readonly name: string; readonly age: number; }, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Either.Either<...>
decodeUnknownEither
(
const Person: Schema.Struct<{ name: typeof Schema.String; age: typeof Schema.Number; }>
Person
, {
(property) ParseOptions.errors?: "first" | "all" | undefined

The `errors` option allows you to receive all parsing errors when attempting to parse a value using a schema. By default only the first error is returned, but by setting the `errors` option to `"all"`, you can receive all errors that occurred during the parsing process. This can be useful for debugging or for providing more comprehensive error messages to the user. default: "first"

errors
: "all" })
9
10
const
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
=
const decode: (u: unknown, overrideOptions?: ParseOptions) => Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
decode
({})
11
if (
import Either
Either
.
const isLeft: <{ readonly name: string; readonly age: number; }, ParseResult.ParseError>(self: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>) => self is Either.Left<...>

Determine if a `Either` is a `Left`.

isLeft
(
const result: Either.Either<{ readonly name: string; readonly age: number; }, ParseResult.ParseError>
result
)) {
12
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
("Decoding failed:")
13
namespace console var console: Console

The `console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream. * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module. _**Warning**_: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for more information. Example using the global `console`: ```js console.log('hello world'); // Prints: hello world, to stdout console.log('hello %s', 'world'); // Prints: hello world, to stdout console.error(new Error('Whoops, something bad happened')); // Prints error message and stack trace to stderr: // Error: Whoops, something bad happened // at [eval]:5:15 // at Script.runInThisContext (node:vm:132:18) // at Object.runInThisContext (node:vm:309:38) // at node:internal/process/execution:77:19 // at [eval]-wrapper:6:22 // at evalScript (node:internal/process/execution:76:60) // at node:internal/main/eval_string:23:3 const name = 'Will Robinson'; console.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ``` Example using the `Console` class: ```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err); myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err const name = 'Will Robinson'; myConsole.warn(`Danger ${name}! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```

console
.
(method) Console.error(message?: any, ...optionalParams: any[]): void

Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.

error
(
import ParseResult
ParseResult
.
const ArrayFormatter: ParseResult.ParseResultFormatter<ParseResult.ArrayFormatterIssue[]>
ArrayFormatter
.
(property) ParseResultFormatter<ArrayFormatterIssue[]>.formatErrorSync: (error: ParseResult.ParseError) => ParseResult.ArrayFormatterIssue[]
formatErrorSync
(
const result: Either.Left<ParseResult.ParseError, { readonly name: string; readonly age: number; }>
result
.
(property) Left<ParseError, { readonly name: string; readonly age: number; }>.left: ParseResult.ParseError
left
))
14
}
15
/*
16
Decoding failed:
17
[
18
{ _tag: 'Missing', path: [ 'name' ], message: 'is missing' },
19
{ _tag: 'Missing', path: [ 'age' ], message: 'is missing' }
20
]
21
*/

If you are working with React and need form validation, @hookform/resolvers offers an adapter for effect/Schema, which can be integrated with React Hook Form for enhanced form validation processes. This integration allows you to leverage the powerful features of effect/Schema within your React applications.

For more detailed instructions and examples on how to integrate effect/Schema with React Hook Form using @hookform/resolvers, you can visit the official npm package page: React Hook Form Resolvers