s-private API Documentation - v3.8.1
    Preparing search index...
    • Wraps entity creation with standardized error handling.

      Type Parameters

      • T

        The type of entity being created

      Parameters

      • factory: () => T

        A function that creates the entity

      Returns T

      The created entity

      This utility function provides consistent error handling across all entity factories. It catches Zod validation errors and converts them to domain-specific error types.

      When Zod validation fails

      For any other unexpected errors

      const article = createEntityWithErrorHandling(() =>
      Object.freeze({
      id: makeId(),
      title: makeArticleTitle(rawTitle),
      // ... other fields
      })
      );