TranslateBatchPolicyError

Error raised when translateBatch() policy configuration chooses fail-fast handling for a structured translation anomaly.

Signature

class TranslateBatchPolicyError<TInput = unknown> extends Error

This exported error class is raised when translateBatch() policy configuration chooses fail-fast handling for a structured translation anomaly.

Usage

import { TranslateBatchPolicyError, translateBatch } from "causal-order/translate"

try {
  translateBatch(records, {
    getEventId: (record) => record.eventId,
    getNodeId: (record) => record.nodeId,
    getPhysicalTime: (record) => record.occurredAt,
    policy: {
      recordFailure: "fail",
      optionalFieldFailure: "warn",
    },
  })
} catch (error) {
  if (error instanceof TranslateBatchPolicyError) {
    console.error(error.anomaly)
  }
}

Details

  • Extends Error and carries the triggering structured anomaly.
  • Raised only when the configured translation policy chooses fail for the encountered anomaly class.
  • Available from both causal-order and the narrower causal-order/translate entrypoint.