(u: unknown): u is EncodingErrorChecks 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.
export const const isEncodingError: (
u: unknown
) => u is EncodingError
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.
isEncodingError = (u: unknownu: unknown): u: unknownu is class EncodingErrorclass EncodingError {
name: string;
message: string;
stack: string;
cause: unknown;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
_tag: Tag;
kind: 'Decode' | 'Encode';
module: string;
input: unknown;
}
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.
EncodingError => hasProperty<"~effect/encoding/EncodingError">(self: unknown, property: "~effect/encoding/EncodingError"): self is { [K in "~effect/encoding/EncodingError"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(u: unknownu, const EncodingErrorTypeId: "~effect/encoding/EncodingError"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.
Literal type of the EncodingErrorTypeId marker.
When to use
Use to type the marker carried by EncodingError values.
EncodingErrorTypeId)