<?php

declare(strict_types=1);

namespace Drupal\flowdrop_session\Exception;

/**
 * Thrown when a turn is requested on a session that is already running one.
 *
 * A turn is a serialized unit: while the session is RUNNING a second
 * concurrent turn is refused (HTTP callers map this to 409 Conflict).
 * AWAITING_INPUT does not raise this — the next user message is the
 * resume and starts a new turn. Plain posts via
 * SessionService::postMessage() are never gated by this exception.
 */
final class ConcurrentTurnException extends \RuntimeException {

  public function __construct(
    public readonly string $sessionId,
  ) {
    parent::__construct(sprintf(
      'Session %s is already running a turn.',
      $sessionId,
    ));
  }

}
