Skip to content

Commit

Permalink
Merge pull request #67 from bookboon/hotfix/error-code
Browse files Browse the repository at this point in the history
fix: include status codes in exceptions
  • Loading branch information
lkm committed Aug 4, 2021
2 parents 5257027 + e397d7c commit ad52409
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Client/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ protected function handleErrorResponse(string $body, array $headers, int $status
case 400:
case 405:
$returnArray = json_decode($body, true);
throw new ApiSyntaxException($this->getFirstError($returnArray));
throw new ApiSyntaxException($this->getFirstError($returnArray), $status);
case 401:
case 403:
$returnArray = json_decode($body, true);
throw new ApiAuthenticationException($this->getFirstError($returnArray, 'Invalid credentials'));
throw new ApiAuthenticationException($this->getFirstError($returnArray, 'Invalid credentials'), $status);
case 410:
case 404:
throw new ApiNotFoundException($url);
throw new ApiNotFoundException($url, $status);
default:
$returnArray = json_decode($body, true);
throw new ApiGeneralException($this->generalExceptionMessage($returnArray ?? [], $headers));
throw new ApiGeneralException($this->generalExceptionMessage($returnArray ?? [], $headers), $status);
}
}

Expand Down

0 comments on commit ad52409

Please sign in to comment.