Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

WorkerError unstable

Typed error model for worker APIs.

This module defines the WorkerError wrapper, the reason variants for spawn, send, receive, and unknown worker failures, a schema union for those reasons, and a guard for recognizing worker errors at runtime.

9 exports Since v4.0.0 Source

Errors

WorkerError

unstable
Since v4.0.0

Error raised by worker APIs, wrapping a specific WorkerErrorReason and exposing its message and cause.

Signature

declare class WorkerError extends {
readonly _tag: "WorkerError";
readonly reason: WorkerSpawnError | WorkerSendError | WorkerReceiveError | WorkerUnknownError;
} & YieldableError<this> {
constructor(props: {
readonly reason: WorkerErrorReason;
});
readonly "~effect/workers/WorkerError": "~effect/workers/WorkerError";
message: string;
}

WorkerErrorReason

type unstable
Since v4.0.0

Union of the specific failure reasons that can be wrapped by a WorkerError.

Signature

type WorkerErrorReason = WorkerSpawnError | WorkerSendError | WorkerReceiveError | WorkerUnknownError
Since v4.0.0

Worker error reason for failures while receiving or handling a message from a worker.

Signature

declare class WorkerReceiveError extends {
readonly _tag: "WorkerReceiveError";
readonly cause?: unknown;
readonly message: string;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "WorkerReceiveError";
readonly cause?: unknown;
readonly message: string;
}, options?: MakeOptions]);
}
Since v4.0.0

Worker error reason for failures while sending a message to a worker.

Signature

declare class WorkerSendError extends {
readonly _tag: "WorkerSendError";
readonly cause?: unknown;
readonly message: string;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "WorkerSendError";
readonly cause?: unknown;
readonly message: string;
}, options?: MakeOptions]);
}
Since v4.0.0

Worker error reason for failures while spawning or setting up a worker.

Signature

declare class WorkerSpawnError extends {
readonly _tag: "WorkerSpawnError";
readonly cause?: unknown;
readonly message: string;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "WorkerSpawnError";
readonly cause?: unknown;
readonly message: string;
}, options?: MakeOptions]);
}
Since v4.0.0

Worker error reason for an unclassified worker failure.

Signature

declare class WorkerUnknownError extends {
readonly _tag: "WorkerUnknownError";
readonly cause?: unknown;
readonly message: string;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "WorkerUnknownError";
readonly cause?: unknown;
readonly message: string;
}, options?: MakeOptions]);
}

Guards

Since v4.0.0

Returns true when a value is a WorkerError.

Signature

declare function isWorkerError(u: unknown): u is WorkerError

Schemas

Since v4.0.0

Schema for decoding and encoding all supported worker error reason variants.

Signature

declare const WorkerErrorReason: Union<[typeof WorkerSpawnError, typeof WorkerSendError, typeof WorkerReceiveError, typeof WorkerUnknownError]>

Type IDs

TypeId

type unstable
Since v4.0.0

Type-level identifier used to brand WorkerError values.

Signature

type TypeId = typeof TypeId