Skip to content

Commit

Permalink
Better error handling (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
asifkhankadiwala committed Nov 30, 2022
1 parent fbd4461 commit bd49175
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/SpotifyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function get(string $endpoint, array $params = []): array
],
]);
} catch (RequestException $e) {
$errorResponse = json_decode($e->getResponse()->getBody()->getContents());
$status = $errorResponse->error->status;
$message = $errorResponse->error->message;
$errorResponse = $e->getResponse();
$status = $errorResponse->getStatusCode();;
$message = $errorResponse->getReasonPhrase();

throw new SpotifyApiException($message, $status, $errorResponse);
}
Expand Down

0 comments on commit bd49175

Please sign in to comment.