1
0
mirror of git://f0xx.org/ac/ac-ms-tickets synced 2026-08-12 18:12:24 +03:00

Tickets: clearer attachment upload error messages.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyeu
2026-08-07 22:15:55 +02:00
parent 3d61c2dc8d
commit 8a7db52268

View File

@@ -93,8 +93,15 @@ final class TicketAttachmentRepository {
if (!$ticket) { if (!$ticket) {
throw new RuntimeException('not found'); throw new RuntimeException('not found');
} }
if (($file['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) { $uploadErr = (int) ($file['error'] ?? UPLOAD_ERR_NO_FILE);
throw new InvalidArgumentException('upload failed'); if ($uploadErr !== UPLOAD_ERR_OK) {
$msg = match ($uploadErr) {
UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE => 'file too large (max 16 MiB)',
UPLOAD_ERR_PARTIAL => 'upload incomplete',
UPLOAD_ERR_NO_FILE => 'no file selected',
default => 'upload failed',
};
throw new InvalidArgumentException($msg);
} }
$size = (int) ($file['size'] ?? 0); $size = (int) ($file['size'] ?? 0);
if ($size <= 0 || $size > self::MAX_BYTES) { if ($size <= 0 || $size > self::MAX_BYTES) {