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

36 lines
747 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,
private readonly PlatformEnum $platform,
?Throwable $previous = null
) {
$message = "Failed to publish article #{$article->id} to {$platform->value}";
if ($previous) {
$message .= ": {$previous->getMessage()}";
}
parent::__construct($message, 0, $previous);
}
public function getArticle(): Article
{
return $this->article;
}
public function getPlatform(): PlatformEnum
{
return $this->platform;
}
}