Skip to content

Commit

Permalink
Merge pull request #170 from akeneo/API-629
Browse files Browse the repository at this point in the history
API-629: Add additional information on exception
  • Loading branch information
fitn authored Sep 9, 2019
2 parents 1f936c3 + 3d4dac5 commit 4d676bb
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Exception/BadRequestHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
*/
class BadRequestHttpException extends ClientErrorHttpException
{
protected function getAdditionalInformationMessage(): string
{
return '(see https://api.akeneo.com/php-client/exception.html#bad-request-exception)';
}
}
4 changes: 4 additions & 0 deletions src/Exception/ClientErrorHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
*/
class ClientErrorHttpException extends HttpException
{
protected function getAdditionalInformationMessage(): string
{
return '(see https://api.akeneo.com/php-client/exception.html#client-exception)';
}
}
7 changes: 7 additions & 0 deletions src/Exception/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class HttpException extends RuntimeException

public function __construct(string $message, RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null)
{
$message .= ' ' . $this->getAdditionalInformationMessage();

parent::__construct($message, $response->getStatusCode(), $previous);

$this->request = $request;
Expand All @@ -43,4 +45,9 @@ public function getResponse(): ResponseInterface
{
return $this->response;
}

protected function getAdditionalInformationMessage(): string
{
return '(see https://api.akeneo.com/php-client/exception.html#http-exception)';
}
}
4 changes: 4 additions & 0 deletions src/Exception/NotFoundHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
*/
class NotFoundHttpException extends ClientErrorHttpException
{
protected function getAdditionalInformationMessage(): string
{
return '(see https://api.akeneo.com/php-client/exception.html#not-found-exception)';
}
}
4 changes: 4 additions & 0 deletions src/Exception/ServerErrorHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
*/
class ServerErrorHttpException extends HttpException
{
protected function getAdditionalInformationMessage(): string
{
return '(see https://api.akeneo.com/php-client/exception.html#server-exception)';
}
}
4 changes: 4 additions & 0 deletions src/Exception/UnauthorizedHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
*/
class UnauthorizedHttpException extends ClientErrorHttpException
{
protected function getAdditionalInformationMessage(): string
{
return '(see https://api.akeneo.com/php-client/exception.html#unauthorized-exception)';
}
}
5 changes: 5 additions & 0 deletions src/Exception/UnprocessableEntityHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ public function getResponseErrors(): array

return isset($decodedBody['errors']) ? $decodedBody['errors'] : [];
}

protected function getAdditionalInformationMessage(): string
{
return '(see https://api.akeneo.com/php-client/exception.html#unprocessable-entity-exception)';
}
}

0 comments on commit 4d676bb

Please sign in to comment.