Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Exceptions;
4
5class BlobException extends SchemaException
6{
7 /**
8 * Create exception for upload failure.
9 */
10 public static function uploadFailed(string $reason): self
11 {
12 return static::withContext(
13 "Blob upload failed: {$reason}",
14 ['reason' => $reason]
15 );
16 }
17
18 /**
19 * Create exception for download failure.
20 */
21 public static function downloadFailed(string $cid, string $reason): self
22 {
23 return static::withContext(
24 "Failed to download blob {$cid}: {$reason}",
25 ['cid' => $cid, 'reason' => $reason]
26 );
27 }
28
29 /**
30 * Create exception for invalid MIME type.
31 */
32 public static function invalidMimeType(string $mimeType, array $accepted): self
33 {
34 return static::withContext(
35 "Invalid MIME type {$mimeType}. Accepted: ".implode(', ', $accepted),
36 ['mimeType' => $mimeType, 'accepted' => $accepted]
37 );
38 }
39
40 /**
41 * Create exception for file size violation.
42 */
43 public static function fileTooLarge(int $size, int $maxSize): self
44 {
45 return static::withContext(
46 "File size {$size} bytes exceeds maximum {$maxSize} bytes",
47 ['size' => $size, 'maxSize' => $maxSize]
48 );
49 }
50}