Skip to content

Commit

Permalink
Small improvements to reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Oct 20, 2014
1 parent d1843a7 commit 3f3144c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/Abstracts/AbstractApiFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public function decode(ResponseInterface $raw, $totalTime = 0)
);
}

if(!isset(
$result->type,
$result->status,
$result->status->message,
$result->status->code,
$result->result)
if(
!property_exists($result, 'type')
|| !property_exists($result, 'status')
|| !property_exists($result, 'result')
|| !property_exists($result->status, 'message')
|| !property_exists($result->status, 'code')
)
{
throw new InvalidApiResponseException("Invalid api result", 500);
Expand Down
6 changes: 4 additions & 2 deletions src/Response/ResponseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public static function create(ApiCallData $data)
{
$type = $data->getResponseType();
$interfaces = class_implements($type);
if(in_array('Packaged\Api\Interfaces\ApiExceptionInterface', $interfaces))
if($type === '\Packaged\Api\Exceptions\ApiException'
|| in_array('\Packaged\Api\Exceptions\ApiException', $interfaces)
)
{
return new $type($data->getStatusCode(), $data->getStatusMessage());
throw new $type($data->getStatusMessage(), $data->getStatusCode());
}
else if(in_array(
'Packaged\Api\Interfaces\ApiResponseInterface',
Expand Down

0 comments on commit 3f3144c

Please sign in to comment.