Skip to content

Commit bd28607

Browse files
committed
Add custom exception for incorrect file
1 parent 5cfe674 commit bd28607

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the zenstruck/filesystem package.
5+
*
6+
* (c) Kevin Bond <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Zenstruck\Filesystem\Exception;
13+
14+
use Symfony\Component\HttpKernel\Exception\HttpException;
15+
16+
/**
17+
* @author Jakub Caban <[email protected]>
18+
*/
19+
class IncorrectFileHttpException extends HttpException
20+
{
21+
22+
}

src/Filesystem/Symfony/HttpKernel/PendingFileValueResolverTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Validator\Validator\ValidatorInterface;
1919
use Symfony\Contracts\Service\ServiceProviderInterface;
2020
use Zenstruck\Filesystem\Attribute\UploadedFile;
21+
use Zenstruck\Filesystem\Exception\IncorrectFileHttpException;
2122
use Zenstruck\Filesystem\Node\File\PendingFile;
2223

2324
/**
@@ -55,7 +56,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
5556
if (\count($errors)) {
5657
\assert($errors instanceof ConstraintViolationList);
5758

58-
throw new HttpException((int) $attribute->errorStatus, (string) $errors);
59+
throw new IncorrectFileHttpException($attribute->errorStatus, (string) $errors);
5960
}
6061
}
6162

0 commit comments

Comments
 (0)