import { BadRequestException } from "@nestjs/common";
import { validateUuidV4OrThrow } from "@customer-portal/domain/common";

export function parseUuidOrThrow(id: string, message = "Invalid ID format"): string {
  try {
    // Domain validator throws its own Error; we translate to a BadRequestException with our message.
    return validateUuidV4OrThrow(id);
  } catch {
    throw new BadRequestException(message);
  }
}
