Skip to content

Commit 405607d

Browse files
committed
Add the exception
1 parent 15d7731 commit 405607d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Client/HttpExceptionHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Akeneo\Pim\ApiClient\Exception\BadRequestHttpException;
66
use Akeneo\Pim\ApiClient\Exception\ClientErrorHttpException;
7+
use Akeneo\Pim\ApiClient\Exception\ForbiddenHttpException;
78
use Akeneo\Pim\ApiClient\Exception\NotFoundHttpException;
89
use Akeneo\Pim\ApiClient\Exception\RedirectionHttpException;
910
use Akeneo\Pim\ApiClient\Exception\ServerErrorHttpException;
@@ -52,6 +53,10 @@ public function transformResponseToException(
5253
throw new UnauthorizedHttpException($this->getResponseMessage($response), $request, $response);
5354
}
5455

56+
if (HttpClient::HTTP_FORBIDDEN === $response->getStatusCode()) {
57+
throw new ForbiddenHttpException($this->getResponseMessage($response), $request, $response);
58+
}
59+
5560
if (HttpClient::HTTP_NOT_FOUND === $response->getStatusCode()) {
5661
throw new NotFoundHttpException($this->getResponseMessage($response), $request, $response);
5762
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Akeneo\Pim\ApiClient\Exception;
4+
5+
/**
6+
* @copyright 2022 Akeneo SAS (http://www.akeneo.com)
7+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8+
*/
9+
class ForbiddenHttpException extends ClientErrorHttpException
10+
{
11+
protected function getAdditionalInformationMessage(): string
12+
{
13+
return '(see https://api.akeneo.com/php-client/exception.html#forbidden-exception)';
14+
}
15+
}

0 commit comments

Comments
 (0)