From dfe921c231568d76d2e43bdb735bde9e55cf72b4 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 23 Jun 2022 13:03:17 +0300 Subject: [PATCH] exception change --- application/Espo/Core/Api/RequestWrapper.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/application/Espo/Core/Api/RequestWrapper.php b/application/Espo/Core/Api/RequestWrapper.php index 9952bccbe7..3d309565e7 100644 --- a/application/Espo/Core/Api/RequestWrapper.php +++ b/application/Espo/Core/Api/RequestWrapper.php @@ -30,7 +30,7 @@ namespace Espo\Core\Api; use Espo\Core\Utils\Json; -use Espo\Core\Exceptions\Error; +use Espo\Core\Exceptions\BadRequest; use Psr\Http\Message\{ ServerRequestInterface as Psr7Request, @@ -184,6 +184,9 @@ class RequestWrapper implements ApiRequest return $contents; } + /** + * @throws BadRequest + */ public function getParsedBody(): stdClass { if ($this->parsedBody === null) { @@ -191,12 +194,15 @@ class RequestWrapper implements ApiRequest } if ($this->parsedBody === null) { - throw new Error(); + throw new BadRequest(); } return Util::cloneObject($this->parsedBody); } + /** + * @throws BadRequest + */ private function initParsedBody(): void { $contents = $this->getBodyContents(); @@ -211,7 +217,7 @@ class RequestWrapper implements ApiRequest } if (!$parsedBody instanceof stdClass) { - throw new Error("Body is not a JSON object."); + throw new BadRequest("Body is not a JSON object."); } $this->parsedBody = $parsedBody;