fedi-feed-router/backend/src/Domains/Platform/Exceptions/ChannelException.php

61 lines
1.8 KiB
PHP
Raw Normal View History

2025-07-05 18:26:04 +02:00
<?php
2025-08-15 16:39:18 +02:00
namespace Domains\Platform\Exceptions;
2025-07-05 18:26:04 +02:00
use Exception;
class ChannelException extends Exception
{
2025-08-16 09:00:46 +02:00
/**
* Exception thrown when no languages match between channel and system
*/
public static function noMatchingLanguages(array $channelLanguages, array $systemLanguages): self
{
$channelLangNames = implode(', ', array_column($channelLanguages, 'name'));
$systemLangNames = implode(', ', array_column($systemLanguages, 'name'));
return new self(
"No matching languages found. Channel supports: [{$channelLangNames}]. " .
"System supports: [{$systemLangNames}]. Please ensure the channel supports " .
"at least one system language."
);
}
/**
* Exception thrown when channel/community is not found
*/
public static function channelNotFound(string $channelName, string $instanceUrl): self
{
return new self(
"Channel '{$channelName}' not found on instance '{$instanceUrl}'. " .
"Please verify the channel name exists on this platform instance."
);
}
/**
* Exception thrown when platform authentication fails
*/
public static function authenticationFailed(string $reason = ''): self
{
$message = 'Failed to authenticate with platform instance';
if ($reason) {
$message .= ": {$reason}";
}
return new self($message);
}
/**
* Exception thrown when platform API is unavailable
*/
public static function platformUnavailable(string $instanceUrl, string $reason = ''): self
{
$message = "Platform instance '{$instanceUrl}' is unavailable";
if ($reason) {
$message .= ": {$reason}";
}
return new self($message);
}
2025-07-05 18:26:04 +02:00
}