From 65e2c71cbf46029307854d0a80e685cdb27494e0 Mon Sep 17 00:00:00 2001 From: Raj Janorkar Date: Fri, 10 Mar 2023 09:18:16 +1000 Subject: [PATCH 1/2] Create MiddlewareException --- src/Exception/MiddlewareException | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/Exception/MiddlewareException diff --git a/src/Exception/MiddlewareException b/src/Exception/MiddlewareException new file mode 100644 index 00000000..5732c06f --- /dev/null +++ b/src/Exception/MiddlewareException @@ -0,0 +1,7 @@ + Date: Fri, 10 Mar 2023 09:22:17 +1000 Subject: [PATCH 2/2] Update Server.php --- src/Tus/Server.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Tus/Server.php b/src/Tus/Server.php index 8c4d3539..2dc2546d 100644 --- a/src/Tus/Server.php +++ b/src/Tus/Server.php @@ -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; @@ -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();