Commit 7bac7c26 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

Add separate exception for missing request body

parent fd47b158
<?php
declare(strict_types = 1);
namespace T3o\Ter\Exception;
......
<?php
declare(strict_types = 1);
namespace T3o\Ter\Exception;
/*
* This file is part of TYPO3 CMS-extension "ter", created by Oliver Bartsch.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/
class RequiredBodyMissingException extends Exception
{
}
......@@ -137,7 +137,7 @@ final class RouteConfiguration implements SingletonInterface
foreach ($parts as $part) {
if (isset($configuration[$part]) && is_array($configuration[$part])) {
$configuration = $configuration[$part];
$configuration = $configuration[$part];
}
}
......
......@@ -17,6 +17,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use T3o\Ter\Exception\RequiredArgumentMissingException;
use T3o\Ter\Exception\RequiredBodyMissingException;
use T3o\Ter\Rest\RouteArgument\RouteArgumentFactory;
use TYPO3\CMS\Core\Routing\RouteResultInterface;
......@@ -87,7 +88,8 @@ final class RouteResolver
&& !$routeResultArguments->hasRouteArgument($parameter['name'])
) {
throw new RequiredArgumentMissingException(
sprintf('%s argument %s is required but is missing in the request.',
sprintf(
'%s argument %s is required but is missing in the request.',
ucfirst($parameter['in']),
$parameter['name']
),
......@@ -103,7 +105,7 @@ final class RouteResolver
$requestBody = $this->routeConfiguration->getParameterConfigurationByReference($requestBody);
}
if ((bool)($requestBody['required'] ?? false) && $request->getParsedBody() === null) {
throw new RequiredArgumentMissingException(
throw new RequiredBodyMissingException(
sprintf('Required request body for %s is missing in the request.', $requestBody['reference']),
1601369655
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment