Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Middleware Exception #425

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Exception/MiddlewareException
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace TusPhp\Exception;

class MiddlewareException extends \Exception
{
}
7 changes: 6 additions & 1 deletion src/Tus/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use TusPhp\Exception\FileException;
use TusPhp\Exception\ConnectionException;
use TusPhp\Exception\OutOfRangeException;
use TusPhp\Exception\MiddlewareException;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Symfony\Component\HttpFoundation\Response as HttpResponse;
Expand Down Expand Up @@ -255,7 +256,11 @@ public function getMaxUploadSize(): int
*/
public function serve()
{
$this->applyMiddleware();
try {
$this->applyMiddleware();
} catch (MiddlewareException $e) {
return $this->response->send($e->getMessage(), $e->getCode());
}

$requestMethod = $this->getRequest()->method();

Expand Down