diff --git a/src/Client.php b/src/Client.php index f841a2f..8b54d82 100644 --- a/src/Client.php +++ b/src/Client.php @@ -150,6 +150,7 @@ protected function request($verb, $uri, array $payload = []) * * @throws \TestMonitor\Mantis\Exceptions\ValidationException * @throws \TestMonitor\Mantis\Exceptions\NotFoundException + * @throws \TestMonitor\Mantis\Exceptions\UnauthorizedException * @throws \TestMonitor\Mantis\Exceptions\FailedActionException * @throws \Exception * @@ -162,15 +163,15 @@ protected function handleRequestError(ResponseInterface $response) } if ($response->getStatusCode() == 404) { - throw new NotFoundException(); + throw new NotFoundException((string) $response->getBody(), $response->getStatusCode()); } if ($response->getStatusCode() == 401 || $response->getStatusCode() == 403) { - throw new UnauthorizedException(); + throw new UnauthorizedException((string) $response->getBody(), $response->getStatusCode()); } if ($response->getStatusCode() == 400) { - throw new FailedActionException((string) $response->getBody()); + throw new FailedActionException((string) $response->getBody(), $response->getStatusCode()); } throw new Exception((string) $response->getStatusCode()); diff --git a/src/Exceptions/FailedActionException.php b/src/Exceptions/FailedActionException.php index 82a0eee..612ad13 100644 --- a/src/Exceptions/FailedActionException.php +++ b/src/Exceptions/FailedActionException.php @@ -4,13 +4,5 @@ class FailedActionException extends Exception { - /** - * Create a new exception instance. - * - * @param string $message - */ - public function __construct($message) - { - parent::__construct($message); - } + // } diff --git a/src/Exceptions/NotFoundException.php b/src/Exceptions/NotFoundException.php index c1f8b7a..fffab6a 100644 --- a/src/Exceptions/NotFoundException.php +++ b/src/Exceptions/NotFoundException.php @@ -4,11 +4,5 @@ class NotFoundException extends Exception { - /** - * Create a new exception instance. - */ - public function __construct() - { - parent::__construct('The resource you are looking for could not be found.'); - } + // } diff --git a/src/Exceptions/UnauthorizedException.php b/src/Exceptions/UnauthorizedException.php index 2b9904a..75b70ee 100644 --- a/src/Exceptions/UnauthorizedException.php +++ b/src/Exceptions/UnauthorizedException.php @@ -4,11 +4,5 @@ class UnauthorizedException extends Exception { - /** - * Create a new exception instance. - */ - public function __construct() - { - parent::__construct(); - } + // } diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php index cd2b5b6..623fee1 100644 --- a/tests/ProjectsTest.php +++ b/tests/ProjectsTest.php @@ -104,7 +104,6 @@ public function it_should_throw_a_unauthorized_exception_when_client_lacks_autho $service->shouldReceive('request')->once()->andReturn($response = Mockery::mock('Psr\Http\Message\ResponseInterface')); $response->shouldReceive('getStatusCode')->andReturn(401); - $response->shouldReceive('getBody')->andReturnNull(); $response->shouldReceive('getBody')->andReturn(\GuzzleHttp\Psr7\Utils::streamFor()); $this->expectException(UnauthorizedException::class);