Skip to content

Commit 18f060b

Browse files
authored
Optimized handling of ValidationException in JSON-RPC core middleware to properly return INVALID_PARAMS error responses.
1 parent 4eace92 commit 18f060b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/CoreMiddleware.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Closure;
1616
use Hyperf\HttpServer\Router\Dispatched;
1717
use Hyperf\Rpc\Protocol;
18+
use Hyperf\Validation\ValidationException;
1819
use InvalidArgumentException;
1920
use Psr\Container\ContainerInterface;
2021
use Psr\Http\Message\ServerRequestInterface;
@@ -48,6 +49,8 @@ protected function handleFound(Dispatched $dispatched, ServerRequestInterface $r
4849
$parameters = $this->parseMethodParameters($controller, $action, $request->getParsedBody());
4950
} catch (InvalidArgumentException) {
5051
return $this->responseBuilder->buildErrorResponse($request, ResponseBuilder::INVALID_PARAMS);
52+
} catch (ValidationException $validationException) {
53+
return $this->responseBuilder->buildErrorResponse($request, ResponseBuilder::INVALID_PARAMS, $validationException);
5154
}
5255

5356
try {

0 commit comments

Comments
 (0)