fedi-feed-router/app/Exceptions/PublishException.php

40 lines
820 B
PHP
Raw Permalink Normal View History

2025-06-30 18:18:30 +02:00
<?php
namespace App\Exceptions;
use App\Enums\PlatformEnum;
use App\Models\Article;
use Exception;
use Throwable;
class PublishException extends Exception
{
public function __construct(
private readonly Article $article,
2025-07-05 18:26:04 +02:00
private readonly PlatformEnum|null $platform,
2025-06-30 18:18:30 +02:00
?Throwable $previous = null
) {
2025-07-05 18:26:04 +02:00
$message = "Failed to publish article #$article->id";
if ($this->platform) {
$message .= " to $platform->value";
}
2025-06-30 18:18:30 +02:00
if ($previous) {
$message .= ": {$previous->getMessage()}";
}
parent::__construct($message, 0, $previous);
}
public function getArticle(): Article
{
return $this->article;
}
2025-07-05 18:26:04 +02:00
public function getPlatform(): ?PlatformEnum
2025-06-30 18:18:30 +02:00
{
return $this->platform;
}
}