Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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());
Comment thread
stefanius marked this conversation as resolved.
}

if ($response->getStatusCode() == 400) {
throw new FailedActionException((string) $response->getBody());
throw new FailedActionException((string) $response->getBody(), $response->getStatusCode());
}

throw new Exception((string) $response->getStatusCode());
Expand Down
10 changes: 1 addition & 9 deletions src/Exceptions/FailedActionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,5 @@

class FailedActionException extends Exception
{
/**
* Create a new exception instance.
*
* @param string $message
*/
public function __construct($message)
{
parent::__construct($message);
}
//
}
8 changes: 1 addition & 7 deletions src/Exceptions/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
//
}
8 changes: 1 addition & 7 deletions src/Exceptions/UnauthorizedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@

class UnauthorizedException extends Exception
{
/**
* Create a new exception instance.
*/
public function __construct()
{
parent::__construct();
}
//
}
1 change: 0 additions & 1 deletion tests/ProjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down