{"version":3,"file":"exceptions.mjs","names":[],"sources":["../../../src/batteries/validation/exceptions.ts"],"sourcesContent":["/**\n * Exceptions raised by the ordering validation battery.\n *\n * @module @nhtio/adk/batteries/validation/exceptions\n */\n\nimport { createException } from '@nhtio/adk/factories'\nimport type { BaseException } from '@nhtio/adk/types'\nimport type { BlockingOrderingViolation } from './types'\n\n/** Thrown when ordering guard options do not satisfy the battery contract. */\nexport const E_INVALID_ORDERING_GUARD_OPTIONS = createException<[string]>(\n  'E_INVALID_ORDERING_GUARD_OPTIONS',\n  'Invalid ordering guard options: %s',\n  'E_INVALID_ORDERING_GUARD_OPTIONS',\n  422,\n  true\n)\n\n/** Thrown when a string profile name is absent from the registered profile catalog. */\nexport const E_UNKNOWN_ORDERING_PROFILE = createException<[string]>(\n  'E_UNKNOWN_ORDERING_PROFILE',\n  'Unknown ordering profile \"%s\"; call orderingProfiles() to list registered profiles.',\n  'E_UNKNOWN_ORDERING_PROFILE',\n  422,\n  true\n)\n\n/** A blocking ordering exception enriched with the complete violation list. */\nexport interface OrderingViolationException extends BaseException {\n  /** Blocking violations that caused the dispatch rejection. */\n  violations: BlockingOrderingViolation[]\n}\n\n/** A repair failure, retaining enough progress to reconcile a partially-mutated store. */\nexport interface OrderingRepairException extends BaseException {\n  /** The original ids in the collision group being repaired. */\n  groupIds: string[]\n  /** Group members deleted before a degraded replacement failed. */\n  deletedIds: string[]\n  /** The persistence or context error that caused the repair to fail. */\n  cause?: unknown\n}\n\n/** Thrown internally when materialising an ordering repair cannot complete. */\nexport const E_ORDERING_REPAIR_FAILED = createException<[string]>(\n  'E_ORDERING_REPAIR_FAILED',\n  'Ordering repair failed: %s',\n  'E_ORDERING_REPAIR_FAILED',\n  422,\n  false\n)\n\n/** Constructs a structured repair failure without losing the underlying store error. */\nexport const createOrderingRepairError = (\n  message: string,\n  cause: unknown,\n  groupIds: string[],\n  deletedIds: string[]\n): OrderingRepairException => {\n  const error = new E_ORDERING_REPAIR_FAILED([message]) as OrderingRepairException\n  error.cause = cause\n  error.groupIds = [...groupIds]\n  error.deletedIds = [...deletedIds]\n  return error\n}\n\n/**\n * Thrown when a dispatch contains blocking ordering violations.\n *\n * @remarks\n * This factory remains compatible with the repository's printf-style exception convention. Use\n * {@link createOrderingViolationError} when the structured violation list is available.\n */\nexport const E_ORDERING_VIOLATION = createException<[number, string]>(\n  'E_ORDERING_VIOLATION',\n  'Ordering guard rejected dispatch: %d violation(s) found (first: %s)',\n  'E_ORDERING_VIOLATION',\n  422,\n  false\n)\n\n/**\n * Constructs an ordering rejection and attaches its typed blocking violation list.\n *\n * @param count - Number of blocking violations.\n * @param firstDetail - Human-readable detail for the first violation.\n * @param violations - Complete list of violations that may feed the rejection path.\n * @returns The enriched exception instance.\n */\nexport const createOrderingViolationError = (\n  count: number,\n  firstDetail: string,\n  violations: BlockingOrderingViolation[]\n): OrderingViolationException => {\n  const error = new E_ORDERING_VIOLATION([count, firstDetail]) as OrderingViolationException\n  error.violations = violations\n  return error\n}\n"],"mappings":";;;;;;;;;AAWA,IAAa,mCAAmC,gBAC9C,oCACA,sCACA,oCACA,KACA,IACF;;AAGA,IAAa,6BAA6B,gBACxC,8BACA,yFACA,8BACA,KACA,IACF;;AAmBA,IAAa,2BAA2B,gBACtC,4BACA,8BACA,4BACA,KACA,KACF;;AAGA,IAAa,6BACX,SACA,OACA,UACA,eAC4B;CAC5B,MAAM,QAAQ,IAAI,yBAAyB,CAAC,OAAO,CAAC;CACpD,MAAM,QAAQ;CACd,MAAM,WAAW,CAAC,GAAG,QAAQ;CAC7B,MAAM,aAAa,CAAC,GAAG,UAAU;CACjC,OAAO;AACT;;;;;;;;AASA,IAAa,uBAAuB,gBAClC,wBACA,uEACA,wBACA,KACA,KACF;;;;;;;;;AAUA,IAAa,gCACX,OACA,aACA,eAC+B;CAC/B,MAAM,QAAQ,IAAI,qBAAqB,CAAC,OAAO,WAAW,CAAC;CAC3D,MAAM,aAAa;CACnB,OAAO;AACT"}