Skip to content

Commit 4d676bb

Browse files
authored
Merge pull request #170 from akeneo/API-629
API-629: Add additional information on exception
2 parents 1f936c3 + 3d4dac5 commit 4d676bb

7 files changed

+32
-0
lines changed

src/Exception/BadRequestHttpException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
*/
1212
class BadRequestHttpException extends ClientErrorHttpException
1313
{
14+
protected function getAdditionalInformationMessage(): string
15+
{
16+
return '(see https://api.akeneo.com/php-client/exception.html#bad-request-exception)';
17+
}
1418
}

src/Exception/ClientErrorHttpException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
*/
1212
class ClientErrorHttpException extends HttpException
1313
{
14+
protected function getAdditionalInformationMessage(): string
15+
{
16+
return '(see https://api.akeneo.com/php-client/exception.html#client-exception)';
17+
}
1418
}

src/Exception/HttpException.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class HttpException extends RuntimeException
2222

2323
public function __construct(string $message, RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null)
2424
{
25+
$message .= ' ' . $this->getAdditionalInformationMessage();
26+
2527
parent::__construct($message, $response->getStatusCode(), $previous);
2628

2729
$this->request = $request;
@@ -43,4 +45,9 @@ public function getResponse(): ResponseInterface
4345
{
4446
return $this->response;
4547
}
48+
49+
protected function getAdditionalInformationMessage(): string
50+
{
51+
return '(see https://api.akeneo.com/php-client/exception.html#http-exception)';
52+
}
4653
}

src/Exception/NotFoundHttpException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
*/
1212
class NotFoundHttpException extends ClientErrorHttpException
1313
{
14+
protected function getAdditionalInformationMessage(): string
15+
{
16+
return '(see https://api.akeneo.com/php-client/exception.html#not-found-exception)';
17+
}
1418
}

src/Exception/ServerErrorHttpException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
*/
1212
class ServerErrorHttpException extends HttpException
1313
{
14+
protected function getAdditionalInformationMessage(): string
15+
{
16+
return '(see https://api.akeneo.com/php-client/exception.html#server-exception)';
17+
}
1418
}

src/Exception/UnauthorizedHttpException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
*/
1212
class UnauthorizedHttpException extends ClientErrorHttpException
1313
{
14+
protected function getAdditionalInformationMessage(): string
15+
{
16+
return '(see https://api.akeneo.com/php-client/exception.html#unauthorized-exception)';
17+
}
1418
}

src/Exception/UnprocessableEntityHttpException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ public function getResponseErrors(): array
2424

2525
return isset($decodedBody['errors']) ? $decodedBody['errors'] : [];
2626
}
27+
28+
protected function getAdditionalInformationMessage(): string
29+
{
30+
return '(see https://api.akeneo.com/php-client/exception.html#unprocessable-entity-exception)';
31+
}
2732
}

0 commit comments

Comments
 (0)