From 9786fe7480c613a82e94eb4c768e97b43c38ab67 Mon Sep 17 00:00:00 2001 From: core23 Date: Sun, 9 Jul 2017 16:54:26 +0200 Subject: [PATCH] Improved exception handling --- src/Connection/HTTPlugConnection.php | 4 ++-- src/Exception/ApiException.php | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Connection/HTTPlugConnection.php b/src/Connection/HTTPlugConnection.php index d7bddfb..15be6b9 100644 --- a/src/Connection/HTTPlugConnection.php +++ b/src/Connection/HTTPlugConnection.php @@ -62,7 +62,7 @@ public function call(string $method, array $params = array(), string $requestMet } catch (ApiException $e) { throw $e; } catch (\Exception $e) { - throw new ApiException('Technical error occurred.', 500); + throw new ApiException('Technical error occurred.', 500, $e); } } @@ -84,7 +84,7 @@ private function parseResponse(ResponseInterface $response): array } if (static::NOT_FOUND_MESSAGE === $content) { - throw new NotFoundException(); + throw new NotFoundException('Server did not find any entity for the request.'); } throw new ApiException($content, $response->getStatusCode()); diff --git a/src/Exception/ApiException.php b/src/Exception/ApiException.php index 0b3bb55..bd0323b 100644 --- a/src/Exception/ApiException.php +++ b/src/Exception/ApiException.php @@ -11,17 +11,6 @@ final class ApiException extends \Exception { - /** - * ApiException constructor. - * - * @param string $message - * @param int $code - */ - public function __construct(string $message, int $code = 0) - { - parent::__construct($message, $code); - } - /** * {@inheritdoc} */