Skip to content

Commit

Permalink
[v1.1.1] scope >200 & <500 error code exception to be external
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Calef committed Sep 27, 2022
1 parent 77b8771 commit b335169
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

namespace Zepgram\Rest\Exception\Result;

use Zepgram\Rest\Exception\InternalException;
use Zepgram\Rest\Exception\ExternalException;

class BusinessException extends InternalException
class ServiceException extends ExternalException
{

}
6 changes: 3 additions & 3 deletions Model/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Throwable;
use Zepgram\Rest\Exception\ExternalException;
use Zepgram\Rest\Exception\InternalException;
use Zepgram\Rest\Exception\Result\BusinessException;
use Zepgram\Rest\Exception\Result\ServiceException;
use Zepgram\Rest\Exception\Result\HttpException;
use Zepgram\Rest\Exception\Result\NotFoundException;
use Zepgram\Rest\Exception\Result\UnserializeException;
Expand Down Expand Up @@ -110,7 +110,7 @@ public function request(ParametersInterface $parameters): string|int|bool|array|
/**
* @param ParametersInterface $parameters
* @return ResponseInterface
* @throws BusinessException
* @throws ServiceException
* @throws HttpException
* @throws NotFoundException
*/
Expand Down Expand Up @@ -138,7 +138,7 @@ private function guzzleRequest(ParametersInterface $parameters): ResponseInterfa
throw new NotFoundException(__('[REST API] %1 not found: %2', $serviceName, $body), $e, $e->getCode());
}
if (!empty($body) && $e->getCode() < 500) {
throw new BusinessException(__('[REST API] %1 error: %2', $serviceName, $body), $e, $e->getCode());
throw new ServiceException(__('[REST API] %1 error: %2', $serviceName, $body), $e, $e->getCode());
}
throw new HttpException(__('[REST API] %1', $serviceName), $e, $e->getCode());
} catch (Throwable $e) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "zepgram/module-rest",
"description": "Technical module to industrialize API REST call with dependency injection pattern using Guzzle library in Magento 2",
"type": "magento2-module",
"version": "1.1.0",
"version": "1.1.1",
"authors": [
{
"name": "Benjamin Calef",
Expand Down

0 comments on commit b335169

Please sign in to comment.