Skip to content
Effect Days 2026 Get your ticket

EncodingError

Shared error type for encoding and decoding operations.

4 exports Added in v4.0.0 Source

Errors

Error returned when an encoding or decoding operation cannot process its input.

When to use

Use when you need to handle or inspect failures from encoding or decoding operations.

Details

The error records whether the failure happened during encoding or decoding, which encoding module reported it, the original input, and a human-readable message.

See

Signature

declare class EncodingError extends YieldableError<this> & {
readonly _tag: "EncodingError";
} & Readonly<{
input: unknown;
kind: "Decode" | "Encode";
message: string;
module: string;
}> {
constructor(args: {
readonly input: unknown;
readonly kind: "Decode" | "Encode";
readonly message: string;
readonly module: string;
});
readonly "~effect/encoding/EncodingError": "~effect/encoding/EncodingError";
}

Guards

Checks whether a value is an EncodingError.

When to use

Use to narrow an unknown value before handling it as an EncodingError from encoding or decoding code.

Details

Returns true when the value carries the EncodingErrorTypeId marker and narrows the value to EncodingError.

See

  • EncodingError for the structured error produced by failed encoding and decoding operations

Signature

declare function isEncodingError(u: unknown): u is EncodingError

Type IDs

Type identifier stored on EncodingError values and used by isEncodingError.

When to use

Use when implementing low-level EncodingError-compatible values that need to carry the runtime marker.

Details

This marker is part of the runtime representation of EncodingError. Prefer isEncodingError when narrowing unknown values.

See

Signature

declare const EncodingErrorTypeId: "~effect/encoding/EncodingError"

EncodingErrorTypeId type

Added in v4.0.0 Source

Literal type of the EncodingErrorTypeId marker.

When to use

Use to type the marker carried by EncodingError values.

Signature

type EncodingErrorTypeId = typeof EncodingErrorTypeId