Hyperlinkv0.8.0-beta.28

PlatformError

PlatformError.PlatformErrorclasseffect/PlatformError.ts:157
PlatformError

Tagged error used by platform APIs to report either invalid arguments or system-level failures.

When to use

Use as the shared error type for platform APIs that expose invalid arguments and host or operating-system failures through a single Effect error channel.

Details

The reason field contains the underlying BadArgument or SystemError. When that reason has a cause, the cause is preserved on the wrapper.

export class PlatformError extends Data.TaggedError("PlatformError")<{
  reason: BadArgument | SystemError
}> {
  constructor(reason: BadArgument | SystemError) {
    if ("cause" in reason) {
      super({ reason, cause: reason.cause } as any)
    } else {
      super({ reason })
    }
  }

  /**
   * Marks this value as a platform error wrapper for runtime guards.
   *
   * **When to use**
   *
   * Use to identify `PlatformError` values through their runtime type marker.
   *
   * @since 4.0.0
   */
  readonly [TypeId]: typeof TypeId = TypeId

  override get message(): string {
    return this.reason.message
  }
}
Referenced by 13 symbols