| 1 |
<?php |
| 2 |
|
| 3 |
namespace AATXT\App\Domain\Exceptions; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
|
| 7 |
/** |
| 8 |
* Exception thrown when an image is invalid or has unsupported MIME type. |
| 9 |
* |
| 10 |
* This exception is thrown when attempting to generate alt text for an image |
| 11 |
* that doesn't meet the provider's requirements (e.g., unsupported format). |
| 12 |
*/ |
| 13 |
class InvalidImageException extends Exception |
| 14 |
{ |
| 15 |
/** |
| 16 |
* Constructor |
| 17 |
* |
| 18 |
* @param int $imageId The WordPress attachment ID |
| 19 |
* @param string $mimeType The MIME type of the image |
| 20 |
* @param array $supportedTypes List of supported MIME types |
| 21 |
*/ |
| 22 |
public function __construct(int $imageId, string $mimeType, array $supportedTypes = []) |
| 23 |
{ |
| 24 |
$supportedList = !empty($supportedTypes) |
| 25 |
? implode(', ', $supportedTypes) |
| 26 |
: 'none specified'; |
| 27 |
|
| 28 |
parent::__construct( |
| 29 |
sprintf( |
| 30 |
'Image ID %d has unsupported MIME type "%s". Supported types: %s', |
| 31 |
$imageId, |
| 32 |
$mimeType, |
| 33 |
$supportedList |
| 34 |
) |
| 35 |
); |
| 36 |
} |
| 37 |
} |
| 38 |
|