wordpress-seo
/
src
/
myyoast-client
/
application
/
exceptions
/
registration-temporarily-unavailable-exception.php
registration-temporarily-unavailable-exception.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/myyoast-client/application/exceptions/registration-temporarily-unavailable-exception.php
| 1 | <?php |
| 2 | // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 3 | |
| 4 | namespace Yoast\WP\SEO\MyYoast_Client\Application\Exceptions; |
| 5 | |
| 6 | /** |
| 7 | * Exception thrown when the server temporarily refuses new Dynamic Client |
| 8 | * Registrations (HTTP 503 `temporarily_unavailable`). |
| 9 | * |
| 10 | * This happens when the registration emergency brake is engaged server-side during |
| 11 | * a controlled rollout. It is a transient condition: the caller should fall back to |
| 12 | * the legacy auth path and try again later. |
| 13 | * |
| 14 | * Extends {@see Registration_Failed_Exception} so existing handlers that catch |
| 15 | * registration failures keep working; handlers that want to surface the suggested |
| 16 | * retry delay can catch this subtype and read {@see self::get_retry_after_seconds()}. |
| 17 | */ |
| 18 | class Registration_Temporarily_Unavailable_Exception extends Registration_Failed_Exception { |
| 19 | |
| 20 | /** |
| 21 | * The server-suggested retry delay in seconds, or null when none was provided. |
| 22 | * |
| 23 | * Display-only: the plugin does not schedule or enforce a wait based on this value. |
| 24 | * |
| 25 | * @var int|null |
| 26 | */ |
| 27 | private $retry_after_seconds; |
| 28 | |
| 29 | /** |
| 30 | * Constructs the exception. |
| 31 | * |
| 32 | * @param string $message The exception message. |
| 33 | * @param int|null $retry_after_seconds The server-suggested retry delay in seconds, or null when unknown. |
| 34 | */ |
| 35 | public function __construct( string $message, ?int $retry_after_seconds = null ) { |
| 36 | parent::__construct( $message ); |
| 37 | |
| 38 | $this->retry_after_seconds = $retry_after_seconds; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the server-suggested retry delay in seconds, or null when none was provided. |
| 43 | * |
| 44 | * @return int|null The retry delay in seconds, or null. |
| 45 | */ |
| 46 | public function get_retry_after_seconds(): ?int { |
| 47 | return $this->retry_after_seconds; |
| 48 | } |
| 49 | } |
| 50 |