60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Domains\Platform\Exceptions;
|
|
|
|
use Exception;
|
|
|
|
class ChannelException extends Exception
|
|
{
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|